local extension = Package("blitz_1st")
extension.extensionName = "zenless__teyvat"
local U = require "packages/utility/utility"

Fk:loadTranslationTable{
    ["blitz_1st"] = "闪击·第一辑",
    ["tey"] = "提瓦特",
    ["blitz"] = "闪击",

    ["Suii"] = "隋",
    ["Xianzhou"] = "仙舟",
    ["IRIS WARBLER"] = "虹莺小队",
    ["Belobog"] = "贝洛伯格",
    ["Void"] = "未知",
    ["Dayan"] = "大炎",
  }

--加入神将开局可选势力，这个不要魔改秋梨膏！隋势力都不算正史可选势力的话那还是删库跑路吧。
Fk:appendKingdomMap("god", {"sui"})

--武将列表（部分缺少数据的已经迁移）
local Eula = General(extension, "blitz__Eula", "Mondstadt", 3, 4, General.Female) 
local Shanxiongxin = General(extension, "blitz__Shanxiongxin", "Suii", 4, 4, General.Male)
local Lingsha = General(extension, "blitz__Lingsha", "Xianzhou", 3, 3, General.Female) 
Lingsha.Hidden = true
local Ayla = General(extension, "blitz__Ayla", "IRIS WARBLER", 3, 3, General.Female)
Ayla.Hidden = true
local Sampo = General(extension, "blitz__Sampo", "Belobog", 4, 4, General.Male) 
local Thirty_Seven = General(extension, "blitz__Thirty_Seven", "west", 3, 3, General.Female) 
local Tingyun = General(extension, "blitz__Tingyun", "Xianzhou", 3, 3, General.Female)
local The_Watcher = General(extension, "blitz__The_Watcher", "Void", 3, 3, General.Male) 
local Zuole = General(extension, "blitz__Zuole", "Dayan", 4, 4, General.Male) 
local Zhaoyun = General(extension, "blitz__Zhaoyun", "shu", 3, 4, General.Male) 
local Ganning = General(extension, "blitz__Ganning", "qun", 4, 4, General.Male)
local Guohuai = General(extension, "blitz__Guohuai", "wei", 4, 4, General.Male) 
local Zhonghui = General(extension, "blitz__Zhonghui", "wei", 4, 4, General.Male) 
local Craite = General(extension, "blitz__Craite", "qun", 4, 4, General.Male)

local blitz__jianbingjuechou = fk.CreateTriggerSkill{
  name = "blitz__jianbingjuechou",
  frequency = Skill.Compulsory,
  events = {fk.PreDamage},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.damageType == fk.NormalDamage
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.damageType = fk.IceDamage
  end,

  refresh_events = {fk.PreCardUse, fk.TurnStart, fk.EventAcquireSkill, fk.EventLoseSkill},
  can_refresh = function (self, event, target, player, data)
    if event == fk.EventAcquireSkill or event == fk.EventLoseSkill then
      return player == target and data == self
    else
      return player:hasSkill(self, true) and (event == fk.TurnStart or player == target)
    end
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    if event == fk.PreCardUse then
      local mark = player:getTableMark("@blitz__jianbing-turn")
      local update = false
      if data.card.type == Card.TypeBasic and table.removeOne(mark, "blitz__jianbing_basic") then
        update = true
        if player:hasSkill(self) then
          data.extraUse = true
        end
      end
      if update then
        room:setPlayerMark(player, "@blitz__jianbing-turn", #mark > 0 and mark or 0)
      end
    elseif event == fk.TurnStart then
      room:setPlayerMark(player, "@blitz__jianbing-turn", {"blitz__jianbing_basic"})
    elseif event == fk.EventAcquireSkill then
      local turn_event = room.logic:getCurrentEvent():findParent(GameEvent.Turn, true)
      if turn_event == nil then return false end
      local b = true
      local use = nil
      room.logic:getEventsByRule(GameEvent.UseCard, 1, function (e)
        use = e.data[1]
        if use.from == player.id then
          if use.card.type == Card.TypeBasic then
            b = false
          end
          return not (b)
        end
      end, turn_event.id)
      local mark = {}
      if b then
        table.insert(mark, "blitz__jianbing_basic")
      end
      room:setPlayerMark(player, "@blitz__jianbing-turn", #mark > 0 and mark or 0)
    elseif event == fk.EventLoseSkill then
      room:setPlayerMark(player, "@blitz__jianbing-turn", 0)
    end
  end,
}
local blitz__yiyanhuanyan = fk.CreateTriggerSkill{
  name = "blitz__yiyanhuanyan",
  switch_skill_name = "blitz__yiyanhuanyan",
  anim_type = "switch",
  events = {fk.Damage, fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local i = 1 + math.max(player:getLostHp(), 1)
    local n = math.max(player:getLostHp(), 1) - 1
    if player:getSwitchSkillState(self.name) == fk.SwitchYang then
      local card = room:askForCard(player, i, i, true, self.name, true, ".", "#blitz__yiyanhuanyan-yang:::"..i)
      if #card > 0 then
      self.cost_data = card
      return true
    end
    else
      return player.room:askForSkillInvoke(player, self.name, nil, "#blitz__yiyanhuanyan-yin:::"..n)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
      room:recastCard(self.cost_data, player, self.name)
    else
      local n = math.max(player:getLostHp(), 1) - 1
      if n > 0 then
      player:drawCards(n, self.name)
      end
    end
  end,
}
local blitz__bingchaowoxuan = fk.CreateTriggerSkill{
  name = "blitz__bingchaowoxuan",
  anim_type = "damage",
  events = {fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      local i = 2 * math.max(player:getLostHp(), 1)
      local y = player:getMark("blitz__Eula_times-turn")
        local room = player.room
        local logic = room.logic
        local end_id = player:getMark("blitz__Eula_record-turn")
        local e = logic:getCurrentEvent()
        if end_id == 0 then
          local turn_event = e:findParent(GameEvent.Turn, false)
          if turn_event == nil then return false end
          end_id = turn_event.id
        end
        room:setPlayerMark(player, "blitz__Eula_record-turn", logic.current_event_id)
        local events = logic.event_recorder[GameEvent.UseCard] or Util.DummyTable
        for i = #events, 1, -1 do
          e = events[i]
          if e.id <= end_id then break end
          local use = e.data[1]
          if use.from == player.id then
            y = y + 1
          end
        end
        events = logic.event_recorder[GameEvent.RespondCard] or Util.DummyTable
        for i = #events, 1, -1 do
          e = events[i]
          if e.id <= end_id then break end
          local use = e.data[1]
          if use.from == player.id then
            y = y + 1
          end
        end
        room:setPlayerMark(player, "blitz__Eula_times-turn", y)
        return y == i
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
      "#blitz__bingchaowoxuan", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:damage{
      from = player,
      to = room:getPlayerById(self.cost_data),
      damage = 1,
      skillName = self.name,
    }
  end,
}
Eula:addSkill(blitz__jianbingjuechou)
Eula:addSkill(blitz__yiyanhuanyan)
Eula:addSkill(blitz__bingchaowoxuan)

Fk:loadTranslationTable{
  ["blitz__Eula"] = "优菈", 
  ["#blitz__Eula"] = "浪花骑士",
  ["cv:blitz__Eula"] = "子音",
  ["illustrator:blitz__Eula"] = "SaK6rA",
  ["designer:blitz__Eula"] = "芺瑟斯Aosas",

  ["blitz__jianbingjuechou"] = "坚冰绝仇",
  [":blitz__jianbingjuechou"] = "锁定技，你造成的无属性伤害均改为冰属性伤害。你每回合使用的第一张基本牌不计入次数。",
  ["blitz__yiyanhuanyan"] = "以眼还眼",
  [":blitz__yiyanhuanyan"] = "转换技，每回合限一次，当你造成或受到伤害后，你可以：阳，重铸X+1张牌；阴，摸X-1张牌（X为你已损失体力值且至少为1）。",
  ["blitz__bingchaowoxuan"] = "冰潮涡旋",
  [":blitz__bingchaowoxuan"] = "当你每回合使用或打出第2X张牌后，你可以对一名其他角色造成1点伤害（X为你已损失体力值且至少为1）。",
  ["@blitz__jianbing-turn"] = "坚冰",
  ["blitz__jianbing_basic"] = "不计",
  ["#blitz__yiyanhuanyan-yang"] = "以眼还眼：是否重铸 %arg 张牌？",
  ["#blitz__yiyanhuanyan-yin"] = "以眼还眼：是否摸 %arg 张牌？",
  ["#blitz__bingchaowoxuan"] = "冰潮涡旋：是否选择一名其他角色，对其造成1点伤害？",

  ["$blitz__jianbingjuechou1"] = "哦？这是对我的挑战吗，我接受了。",
  ["$blitz__jianbingjuechou2"] = "你这家伙，是在报复我吗？",
  ["$blitz__yiyanhuanyan1"] = "以眼还眼！",
  ["$blitz__yiyanhuanyan2"] = "以霜还怨！",
  ["$blitz__bingchaowoxuan1"] = "坚冰，断绝深仇！",
  ["$blitz__bingchaowoxuan2"] = "冰浪怒涛！",
  ["~blitz__Eula"] = "罪人的结局吗…",
} --优菈(完成)

local blitz__longyi = fk.CreateTriggerSkill{
  name = "blitz__longyi",
  mute = true,
  anim_type = "offensive",
  events = {fk.EventPhaseEnd, fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseEnd then
    return target == player and player:hasSkill(self) and player.phase == Player.Draw
    elseif event == fk.TurnEnd then
    return target == player and player:hasSkill(self)
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseEnd then
      player:broadcastSkillInvoke(self.name, math.random(2))
      local targets = {}
      for _, p in ipairs(room:getAlivePlayers()) do
        table.insert(targets, p)
      end
    for _, p in ipairs(targets) do
      if not p.dead then
      local choices = {"slashplus","limitplus","cancel"}
      local choice = room:askForChoice(p, choices, self.name, "#blitz__longyi-support::"..player.id, false, {"slashplus","limitplus","cancel"})
      if choice == "slashplus" then
      room:addPlayerMark(player, MarkEnum.SlashResidue.."-turn", 1)
      elseif choice == "limitplus" then
      room:addPlayerMark(player, MarkEnum.AddMaxCards.."-turn", 1)
      end
      end
    end
  elseif event == fk.TurnEnd then
    player:broadcastSkillInvoke(self.name, math.random(3,4))
    local x = 0
    if player:usedCardTimes("slash", Player.HistoryTurn) >= player:getMark("blitz__longyi-turn") then
      x = x + 1
    end
    if player:getHandcardNum() >= player:getMaxCards() then
      x = x + 1
    end
    player:drawCards(2*x, self.name)
    end
  end,

  refresh_events = {fk.EventPhaseEnd},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Play
  end,
  on_refresh = function(self, event, target, player, data)
    local card = Fk:cloneCard("slash")
    local n = card.skill:getMaxUseTime(player, Player.HistoryPhase, card, nil) or 0
    if player:getMark("blitz__longyi-turn") ~= n then
      player.room:setPlayerMark(player, "blitz__longyi-turn", n)
    end
  end,
}
local blitz__hanjun = fk.CreateTriggerSkill{
  name = "blitz__hanjun",
  mute = true,
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return data.card and data.card.trueName == "slash" and player:hasSkill(self) and target == player
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local invoke = player.room:askForSkillInvoke(player, self.name, nil, "#blitz__hanjun")
    if invoke then
    local card = room:askForCard(player, 0, 3, true, self.name, false, ".", "#blitz__hanjun_ask:")
    if card then
      self.cost_data = card
      return true
    end
  else
    return false
  end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, id in ipairs(TargetGroup:getRealTargets(data.tos)) do
      if string.find(room:getPlayerById(id).general, "lishimin") then
        player:broadcastSkillInvoke(self.name, 3)
      else
        player:broadcastSkillInvoke(self.name, math.random(2))
      end
    end
    room:recastCard(self.cost_data, player, self.name)
    local x = 3 - #self.cost_data
    if x <= 0 then return false end
    local number
      local choices = {}
      for i = 0, x do
        table.insert(choices, tostring(i))
      end
      number = tonumber(player.room:askForChoice(player, choices, self.name, "#blitz__hanjun-minus")) ---@type integer
      if number <= 0 then return false end
      room:addPlayerMark(player, "@blitz__hanjun", number)
      for _, id in ipairs(TargetGroup:getRealTargets(data.tos)) do
        if not room:getPlayerById(id).dead then
        room:addPlayerMark(room:getPlayerById(id), "@blitz__hanjun", number)
        end
      end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room.alive_players) do
      for _, move in ipairs(data) do
        if move.from == p.id and p:getMark("@blitz__hanjun") > 0 and move.moveReason == fk.ReasonDiscard then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
              return true
            end
          end
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room.alive_players) do
      room:setPlayerMark(p, "@blitz__hanjun", 0)
    end
  end,
}
local blitz__hanjun_maxcards = fk.CreateMaxCardsSkill{
  name = "#blitz__hanjun_maxcards",
  global = true,
  correct_func = function(self, player)
    return -player:getMark("@blitz__hanjun")
  end,
}
blitz__hanjun:addRelatedSkill(blitz__hanjun_maxcards)
Shanxiongxin:addSkill(blitz__longyi)
Shanxiongxin:addSkill(blitz__hanjun)

Fk:loadTranslationTable{
  ["blitz__Shanxiongxin"] = "单雄信", 
  ["#blitz__Shanxiongxin"] = "天地勤良",
  ["cv:blitz__Shanxiongxin"] = "幽蝶化烬",
  ["illustrator:blitz__Shanxiongxin"] = "未知",
  ["designer:blitz__Shanxiongxin"] = "廷玉",

  ["blitz__longyi"] = "拢义",
  [":blitz__longyi"] = "摸牌阶段结束时，所有角色可以依次选择一项：令你本回合手牌上限+1；或令你本回合使用【杀】的次数+1。回合结束时，你每有一项达到上限，摸两张牌。",
  ["blitz__hanjun"] = "撼钧",
  [":blitz__hanjun"] = "你使用【杀】后可重铸至多三张牌，然后每少重铸一张，你便可以令你与目标角色的手牌上限均-1直至有一方弃置牌。",
  ["#blitz__longyi-support"] = "拢义 发动，请选择为 %dest 本回合助力的一项。",
  ["slashplus"] = "令其增加本回合出杀次数",
  ["limitplus"] = "令其增加本回合手牌上限",
  ["alllimitminus"] = "与所有目标减少1点手牌上限",
  ["#blitz__hanjun"] = "是否发动 撼钧？",
  ["#blitz__hanjun_ask"] = "发动 撼钧 ，请重铸0~3张牌，不选牌则为0",
  ["#blitz__hanjun-minus"] = "撼钧：选择一个数字，令你与目标角色的手牌上限均减少等量值",
  ["@blitz__hanjun"] = "撼钧",

  ["$blitz__longyi1"] = "取九曲黄河之水，足山东英雄豪饮！",
  ["$blitz__longyi2"] = "歃五彩公鸡之血，彰瓦岗义寨威名！",
  ["$blitz__longyi3"] = "酒气未歇，还请诸座将军助鼓！",
  ["$blitz__longyi4"] = "恩仇未泯，待有来日对阵厮杀！",
  ["$blitz__hanjun1"] = "万军气聚犹觉小，横当宇内尚嫌轻！",
  ["$blitz__hanjun2"] = "东追隋帝，西讨贼王，所仗唯平生肝胆！",
  ["$blitz__hanjun3"] = "你我兄弟，从此诀别！（对李世民发动）",
  ["~blitz__Shanxiongxin"] = "既见万世雄主，天下绥定，又何为死不瞑目?",
} --单雄信(完成)

local blitz__zhuran_fireAttackSkill = fk.CreateActiveSkill{
  name = "blitz__zhuran_fireAttackSkill",
  prompt = "#blitz__zhuran_fireAttackSkill",
  can_use = Util.CanUse,
  target_num = 1,
  mod_target_filter = function(_, to_select, _, _, _, _)
    local to = Fk:currentRoom():getPlayerById(to_select)
    return not to:isKongcheng()
  end,
  target_filter = function(self, to_select, selected, _, card, extra_data, player)
    return Util.TargetFilter(self, to_select, selected, _, card, extra_data, player) and
      self:modTargetFilter(to_select, selected, player, card)
  end,
  on_effect = function(self, room, cardEffectEvent)
    local from = room:getPlayerById(cardEffectEvent.from)
    local to = room:getPlayerById(cardEffectEvent.to)
    if to:isKongcheng() then return end
    local showCard = room:askForCard(to, 1, 999, false, self.name, false, ".|.|.|hand", "#blitz__zhuran_fire_attack-show:" .. from.id)
    local suit = ".|.|" --接下来就是插入花色pattern的地狱判断
    local x = 0
    for _, id in ipairs(showCard) do
      if Fk:getCardById(id).suit == Card.Heart then
        suit = (suit ~= ".|.|" and suit..",heart") or suit.."heart"
      end
      if Fk:getCardById(id).suit == Card.Diamond then
        suit = (suit ~= ".|.|" and suit..",diamond") or suit.."diamond"
      end
      if Fk:getCardById(id).suit == Card.NoSuit then
        suit = (suit ~= ".|.|" and suit..",no_suit") or suit.."no_suit"
      end
      if Fk:getCardById(id).suit == Card.Spade then
        suit = (suit ~= ".|.|" and suit..",spade") or suit.."spade"
      end
      if Fk:getCardById(id).suit == Card.Club then
        suit = (suit ~= ".|.|" and suit..",club") or suit.."club"
      end
      if Fk:getCardById(id):getMark("@@blitz__zhuran-inhand-round") == 1 then
      x = x + 1
      end
    end
    if table.every(showCard, function (id) return Fk:getCardById(id):getMark("@@blitz__zhuran-inhand-round") == 1 end)
    and x > 0 then
      x = x - 1  --如果所有展示牌都有朱燃标记，其中一张为额定展示牌，不参与减伤
    end
    to:showCards(showCard)
    local cards = room:askForCard(from, 1, 999, false, self.name, true,
      suit, "#blitz__zhuran_fire_attack-discard:" .. to.id)
    local y = 0
    if #cards > 0 then
      y = y + 1
      for _, id in ipairs(cards) do
        if Fk:getCardById(id):getMark("@@blitz__zhuran-inhand-round") == 1 then
        y = y + 1
        end
      end
      if table.every(cards, function (id) return Fk:getCardById(id):getMark("@@blitz__zhuran-inhand-round") == 1 end) then
        y = y - 1  --如果所有弃置牌都有朱燃标记，其中一张为额定弃置牌，不参与加伤
      end
    end
    room:throwCard({cards}, self.name, from, from)
    local z = y - x
    if z > 0 and not to.dead then
      room:damage({
        from = from,
        to = to,
        card = cardEffectEvent.card,
        damage = z ,
        damageType = fk.FireDamage,
        skillName = self.name
      })
    elseif z < 0 and to:isWounded() and not to.dead then
      room:recover({
        who = to,
        num = math.min(to:getLostHp(), math.abs(z)),
        card = cardEffectEvent.card,
        recoverBy = from,
        skillName = self.name
      })
    end
  end,
}
blitz__zhuran_fireAttackSkill.cardSkill = true
Fk:addSkill(blitz__zhuran_fireAttackSkill)
local blitz__zhuran = fk.CreateViewAsSkill{
  name = "blitz__zhuran",
  anim_type = "offensive",
  pattern = "fire_attack",
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    local c = Fk:cloneCard("fire_attack")
    c.skill = blitz__zhuran_fireAttackSkill
    c.skillName = self.name
    return c
  end,
  before_use = function(self, player, use)
    local room = player.room
    use.extra_data = use.extra_data or {}
    use.extra_data.blitzzhuran_user = player.id
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  enabled_at_response = Util.FalseFunc,
}
local blitz__zhuran_record = fk.CreateTriggerSkill{
  name = "#blitz__zhuran_record",

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(blitz__zhuran, true)
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, move in ipairs(data) do
      if move.toArea == Player.Hand then
        for _, info in ipairs(move.moveInfo) do
          local id = info.cardId
          if room:getCardArea(id) == Card.PlayerHand then
            room:setCardMark(Fk:getCardById(id), "@@blitz__zhuran-inhand-round", 1)
          end
        end
      end
    end
  end,
}
local blitz__zhuran_active = fk.CreateViewAsSkill{
  name = "blitz__zhuran&",
  anim_type = "offensive",
  pattern = "fire_attack",
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    local c = Fk:cloneCard("fire_attack")
    c.skill = blitz__zhuran_fireAttackSkill
    c.skillName = "blitz__zhuran"
    return c
  end,
  before_use = function(self, player, use)
    local room = player.room
    player:broadcastSkillInvoke("blitz__zhuran")
    use.extra_data = use.extra_data or {}
    use.extra_data.blitzzhuran_user = player.id
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  enabled_at_response = Util.FalseFunc,
}
local blitz__zhuran_trigger = fk.CreateTriggerSkill{
  name = "#blitz__zhuran_trigger",
  mute = true,
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return not player.dead and table.contains(data.card.skillNames, "blitz__zhuran")
    and data.extra_data and data.extra_data.blitzzhuran_user == player.id 
    and table.find(TargetGroup:getRealTargets(data.tos), function(pid) return not player.room:getPlayerById(pid).dead
    and not (data.damageDealt and data.damageDealt[pid]) end)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, pid in ipairs(TargetGroup:getRealTargets(data.tos)) do
      if player.dead then break end
      local to = room:getPlayerById(pid)
      if not to.dead and not(data.damageDealt and data.damageDealt[to.id]) then
        for _, p in ipairs(room:getAllPlayers()) do
          room:handleAddLoseSkills(p, "-blitz__zhuran&", nil, false, true)
        end
        if not to:hasSkill("blitz__zhuran", true) then
        room:handleAddLoseSkills(to, "blitz__zhuran&", nil, false, true)
        end
      end
    end
  end,
}
local blitz__xinxiang = fk.CreateTriggerSkill{
  name = "blitz__xinxiang",
  events = {fk.DamageCaused, fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and not data.from.dead and not data.to.dead
  end,
  on_cost = function(self, event, target, player, data)
    if player:getMark("@@blitz__xinxiang_must") == 0 then
      return player.room:askForSkillInvoke(player, self.name, nil, "#blitz__xinxiang-invoke")
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = {"blitz__xinxiang_draw"}
    if player:getMark("@@blitz__xinxiang_must") == 1 then table.insert(choices, 1, "blitz__xinxiang_discard") end
    local choice = player.room:askForChoice(player, choices, self.name, "#blitz__xinxiang-choice", false, {"blitz__xinxiang_draw", "blitz__xinxiang_discard"})
    if choice == "blitz__xinxiang_draw" then
      local to1 = room:getPlayerById(data.from.id)
      local to2 = room:getPlayerById(data.to.id)
      if not to1.dead then
        room:drawCards(to1, data.damage, self.name)
      end
      if not to2.dead then
        room:drawCards(to2, data.damage, self.name)
      end
    room:setPlayerMark(player, "@@blitz__xinxiang_must", 1)
    return true
  else
    room:handleAddLoseSkills(player, "-blitz__xinxiang", nil, false, false)
    end
  end,

  refresh_events = {fk.RoundEnd},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(self, true) and player:getMark("@@blitz__xinxiang_must") == 1
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:handleAddLoseSkills(player, "-blitz__xinxiang", nil, false, false)
    player.room:setPlayerMark(player, "@@blitz__xinxiang_must", 0)
  end,

  on_lose = function (self, player, is_death)
    player.room:setPlayerMark(player, "@@blitz__xinxiang_must", 0)
  end,
}
Fk:addSkill(blitz__zhuran_active)
blitz__zhuran:addRelatedSkill(blitz__zhuran_record)
blitz__zhuran:addRelatedSkill(blitz__zhuran_trigger)
Lingsha:addSkill(blitz__zhuran)
Lingsha:addSkill(blitz__xinxiang)
Fk:loadTranslationTable{
  ["blitz__Lingsha"] = "灵砂", 
  ["#blitz__Lingsha"] = "乘馨流沁",
  ["cv:blitz__Lingsha"] = "饶梓君",
  ["illustrator:blitz__Lingsha"] = "冰鲜鱼子酱",
  ["designer:blitz__Lingsha"] = "七汐月",

  ["blitz__zhuran"] = "朱燃",
  [":blitz__zhuran"] = "你或上名未受到此牌伤害的目标出牌阶段限一次，你可以视为使用可额外展示或弃置牌的【火攻】，"..
  "每额外展示或弃置一张本轮获得的牌，伤害值-1/+1。(若伤害值为负，改为回复绝对值点体力)",
  ["blitz__xinxiang"] = "心乡",
  [":blitz__xinxiang"] = "你造成或受到伤害时，可以改为与对方各摸伤害值张牌，你下次放弃发动本技能或本轮结束时，失去本技能。",
  ["@@blitz__zhuran-inhand-round"] = "朱燃",
  ["blitz__zhuran&"] = "朱燃",
  [":blitz__zhuran&"] = "衍生，出牌阶段限一次，你可以视为使用可额外展示或弃置牌的【火攻】，"..
  "每额外展示或弃置一张本轮获得的牌，伤害值-1/+1。(若伤害值为负，改为回复绝对值点体力；若未造成伤害，目标角色获得此技能。)",
  ["#blitz__zhuran_trigger"] = "朱燃",
  ["#blitz__zhuran_fire_attack-show"] = "%src 对你使用了火攻，请展示至少一张手牌<br>（每额外展示一张朱燃牌，此牌伤害-1，若均展示朱燃牌，其中一张不计入减伤）",
  ["#blitz__zhuran_fire_attack-discard"] = "你可弃置至少一张展示牌中包含花色的手牌，对 %src 造成若干点火属性伤害"..
  "<br>（每额外弃置一张朱燃牌，此牌伤害+1，若均弃置朱燃牌，其中一张不计入加伤）",
  ["#blitz__zhuran_fireAttackSkill"] = "选择一名有手牌的角色，令其展示至少一张手牌，<br/>然后你可以弃置至少一张与展示牌花色相同的手牌对其造成若干点火焰伤害（详见技能）",
  ["blitz__zhuran_fireAttackSkill"] = "火攻",
  ["@@blitz__xinxiang_must"] = "心乡 必发",
  ["#blitz__xinxiang-invoke"] = "是否发动 心乡 ，防止即将到来的伤害？（然后你下次取消发动或本轮结束后失去本技能）",
  ["blitz__xinxiang_draw"] = "摸牌，防止伤害",
  ["blitz__xinxiang_discard"] = "取消发动，失去本技能",
  ["#blitz__xinxiang-choice"] = "心乡：请选择一项。",

  ["$blitz__zhuran1"] = "金鳞燃犀，洞若观火。",
  ["$blitz__zhuran2"] = "氤氲无穷，篆烟不息。",
  ["$blitz__xinxiang1"] = "安息散、炎龙涎，混上沉霞烬，调了一剂焚香，取名「忘忧」。分您一些吧？",
  ["$blitz__xinxiang2"] = "世间种种…不过是过眼云烟。",
  ["~blitz__Lingsha"] = "烟消…火灭…",
} --灵砂(完成)

local blitz__bujuedechuangzuoyu = fk.CreateViewAsSkill{
  name = "blitz__bujuedechuangzuoyu",
  anim_type = "drawcard",
  pattern = "ex_nihilo",
  prompt = function (self)
   return "#blitz__bujuedechuangzuoyu"..Self:getMark("Ayla_chuangzuoyu-turn")..":"..Self:getMark("Ayla_bujuede-turn")
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and table.contains(Self:getTableMark("@blitz__Ayla-turn"), Fk:getCardById(to_select):getSuitString(true))
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard("ex_nihilo")
    card.skillName = self.name
    card:addSubcard(cards[1])
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    use.extra_data = use.extra_data or {}
    use.extra_data.chuangzuoyu_user = player.id
  end,
  enabled_at_response = function(self, player, response)
    return not response and Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("ex_nihilo"))
  end,
}
local blitz__bujuedechuangzuoyu_recorder = fk.CreateTriggerSkill{
  name = "#blitz__bujuedechuangzuoyu_recorder",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    local x = player:getMark("Ayla_chuangzuoyu-turn")
    local y = player:getMark("Ayla_bujuede-turn")
    return not player.dead and table.contains(data.card.skillNames, "blitz__bujuedechuangzuoyu")
    and data.extra_data and data.extra_data.chuangzuoyu_user == player.id and x > y
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:handleAddLoseSkills(player, "-blitz__bujuedechuangzuoyu", nil, false, true)
  end,

  refresh_events = {fk.AfterCardUseDeclared, fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    if event == fk.AfterCardUseDeclared then
    return target == player and player:hasSkill(self.name, true)
    elseif event == fk.AfterCardsMove then
      for _, move in ipairs(data) do
        if move.moveReason == fk.ReasonDraw and move.skillName == "ex_nihilo" and #move.moveInfo > 0 then
          local use_event = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
          if use_event ~= nil then
          local use = use_event.data[1]
          if (use.extra_data or {}).chuangzuoyu_user == player.id and player:hasSkill(self.name, true) then
          self.cost_data = #move.moveInfo
          return true
          end
        end
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
  if event == fk.AfterCardUseDeclared then
    if not table.contains(data.card.skillNames, "blitz__bujuedechuangzuoyu") then
    player.room:addPlayerMark(player, "Ayla_bujuede-turn", 1)
    end
    local mark = player:getTableMark("@blitz__Ayla-turn")
    table.insertIfNeed(mark, data.card:getSuitString(true))
    player.room:setPlayerMark(player, "@blitz__Ayla-turn", #mark and mark or 0)
  elseif event == fk.AfterCardsMove then
    player.room:addPlayerMark(player, "Ayla_chuangzuoyu-turn", self.cost_data)
  end
  end,

  on_acquire = function (self, player, is_start)
    if not is_start then
      local room = player.room
      local mark = {}
      room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local use = e.data[1]
        if use.from == player.id then
          table.insertIfNeed(mark, use.card:getSuitString(true))
        end
      end, Player.HistoryTurn)
      if #mark > 0 then
        room:setPlayerMark(player, "@blitz__Ayla-turn", #mark and mark or 0)
      end
    end
  end,
}
local blitz__xuanlanjixingxiu = fk.CreateViewAsSkill{
  name = "blitz__xuanlanjixingxiu",
  prompt = function (self)
    return "#blitz__xuanlanjixingxiu:::"..Self:getMark("Ayla_xuanlan-turn")..":"..Self:getMark("Ayla_jixingxiu-turn")
  end,
  pattern = ".",
  anim_type = "special",
  card_filter = function(self, to_select, selected)
    return Self:getMark("@adaptation-turn") ~= 0 and #selected == 0
    and not table.contains(Self:getTableMark("@blitz__Ayla-turn"), Fk:getCardById(to_select):getSuitString(true))
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard(Self:getMark("@adaptation-turn"))
    card.skillName = self.name
    card:addSubcard(cards[1])
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    use.extra_data = use.extra_data or {}
    use.extra_data.jixingxiu_user = player.id
  end,
  enabled_at_play = function(self, player)
    if player:getMark("@adaptation-turn") ~= 0 then
    local to_use = Fk:cloneCard(player:getMark("@adaptation-turn"))
    return to_use.skill:canUse(player, to_use) and not player:prohibitUse(to_use)
    end
  end,
  enabled_at_response = function(self, player, response)
    if response then return false end
    if player:getMark("@adaptation-turn") ~= 0 then
    local to_use = Fk:cloneCard(player:getMark("@adaptation-turn"))
    return (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(to_use))
    end
  end,
}
local blitz__xuanlanjixingxiu_recorder = fk.CreateTriggerSkill{
  name = "#blitz__xuanlanjixingxiu_recorder",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    local x = 0
    player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 999, function(e)
    local damage = e.data[5]
    if damage and damage.from == player then
      x = x + damage.damage
    end
    end, Player.HistoryTurn)
    local y = 0
    player.room.logic:getEventsOfScope(GameEvent.MoveCards, 999, function(e)
      for _, move in ipairs(e.data) do
      if move.to == player.id and move.toArea == Card.PlayerHand then
        y = y + #move.moveInfo
      end
      end
    end, Player.HistoryTurn)
     return not player.dead and table.contains(data.card.skillNames, "blitz__xuanlanjixingxiu")
     and data.extra_data and data.extra_data.jixingxiu_user == player.id and x > y
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:handleAddLoseSkills(player, "-blitz__xuanlanjixingxiu", nil, false, true)
  end,

refresh_events = {fk.AfterCardUseDeclared, fk.PreCardUse, fk.PreCardRespond, fk.AfterCardsMove, fk.Damage},
  can_refresh = function(self, event, target, player, data)
    if event == fk.AfterCardUseDeclared or event == fk.Damage then
    return target == player and player:hasSkill(self.name, true)
    elseif event == fk.PreCardUse or event == fk.PreCardRespond then
    return target == player and player:hasSkill(self.name, true)
    and (data.card.type == Card.TypeBasic or data.card:isCommonTrick())
  elseif event == fk.AfterCardsMove then
    for _, move in ipairs(data) do
      return move.to == player.id and move.toArea == Card.PlayerHand and player:hasSkill(self.name, true)
    end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local mark = player:getTableMark("@blitz__Ayla-turn")
    if event == fk.AfterCardUseDeclared then
    table.insertIfNeed(mark, data.card:getSuitString(true))
    player.room:setPlayerMark(player, "@blitz__Ayla-turn", mark)
  elseif event == fk.PreCardUse or event == fk.PreCardRespond then
    player.room:setPlayerMark(player, "@adaptation-turn", data.card.name)
  else
    local x = 0
    player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 999, function(e)
    local damage = e.data[5]
    if damage and damage.from == player then
      x = x + damage.damage
    end
    end, Player.HistoryTurn)
    local y = 0
    player.room.logic:getEventsOfScope(GameEvent.MoveCards, 999, function(e)
      for _, move in ipairs(e.data) do
      if move.to == player.id and move.toArea == Card.PlayerHand then
        y = y + #move.moveInfo
      end
      end
    end, Player.HistoryTurn)
    player.room:setPlayerMark(player, "Ayla_xuanlan-turn", x)
    player.room:setPlayerMark(player, "Ayla_jixingxiu-turn", y)
    end
  end,

  on_acquire = function (self, player, is_start)
    if not is_start then
      local room = player.room
      local mark = {}
      room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local use = e.data[1]
        if use.from == player.id then
          table.insertIfNeed(mark, use.card:getSuitString(true))
          if use.card.type == Card.TypeBasic or use.card:isCommonTrick() then
            room:setPlayerMark(player, "@adaptation-turn", use.card.name)
          end
        end
      end, Player.HistoryTurn)
      if #mark > 0 then
        room:setPlayerMark(player, "@blitz__Ayla-turn", #mark and mark or 0)
      end
      local x = 0
      room.logic:getEventsOfScope(GameEvent.ChangeHp, 999, function(e)
        local damage = e.data[5]
      if damage and damage.from == player then
        x = x + damage.damage
      end
      end, Player.HistoryTurn)
      local y = 0
        room.logic:getEventsOfScope(GameEvent.MoveCards, 999, function(e)
      for _, move in ipairs(e.data) do
      if move.to == player.id and move.toArea == Card.PlayerHand then
        y = y + #move.moveInfo
      end
      end
      end, Player.HistoryTurn)
      room:setPlayerMark(player, "Ayla_xuanlan-turn", x)
      room:setPlayerMark(player, "Ayla_jixingxiu-turn", y)
    end
  end,
}
blitz__bujuedechuangzuoyu:addRelatedSkill(blitz__bujuedechuangzuoyu_recorder)
blitz__xuanlanjixingxiu:addRelatedSkill(blitz__xuanlanjixingxiu_recorder)
Ayla:addSkill(blitz__bujuedechuangzuoyu)
Ayla:addSkill(blitz__xuanlanjixingxiu)
Fk:loadTranslationTable{
  ["blitz__Ayla"] = "艾拉·万华", 
  ["#blitz__Ayla"] = "竞跃纷斓",
  ["cv:blitz__Ayla"] = "巩大方",
  ["illustrator:blitz__Ayla"] = "战双帕弥什",
  ["designer:blitz__Ayla"] = "永乐",

  --[[["blitz__bujuedechuangzuoyu"] = "灵感喷泉",
  [":blitz__bujuedechuangzuoyu"] = "你可将你本回合已使用过的花色的牌当【无中生有】使用，然后若你本回合因此获得的牌数大于你本回合不因此使用的牌数，你失去此技能。",
  ["blitz__xuanlanjixingxiu"] = "群青跃动",
  [":blitz__xuanlanjixingxiu"] = "你可将你本回合未使用过的花色的牌当【随机应变】使用，然后若你本回合造成伤害数大于你本回合获得牌数，你失去此技能。",
  ["#blitz__bujuedechuangzuoyu"] = "灵感喷泉：选择一张牌当【无中生有】使用，请注意：本回合（你已因此获得%arg张牌/你已使用%arg2张牌），前者大于后者时你失去本技能。",
  ["#blitz__xuanlanjixingxiu"] = "群青跃动：选择一张牌当【随机应变】使用，请注意：本回合（你已造成%arg点伤害/你已获得%arg2张牌），前者大于后者时你失去本技能。", ]]
  ["blitz__bujuedechuangzuoyu"] = "灵感喷泉",
  [":blitz__bujuedechuangzuoyu"] = "你可将你本回合已使用过的花色的牌当【无中生有】使用，然后若你连续使用同名牌或连续发动相同技能，本技能本阶段失效。",
  ["blitz__xuanlanjixingxiu"] = "群青跃动",
  [":blitz__xuanlanjixingxiu"] = "你可将你本回合未使用过的花色的牌当【随机应变】使用，然后若你连续使用同名牌或连续发动相同技能，本技能本阶段失效。",
  ["#blitz__bujuedechuangzuoyu"] = "灵感喷泉：选择一张牌当【无中生有】使用，请注意：本回合你上一个发动的技能是（），此次发动后你失去本技能。",
  ["#blitz__xuanlanjixingxiu"] = "群青跃动：选择一张牌当【随机应变】使用，请注意：本回合你上一个发动的技能是（），此次发动后你失去本技能。",
  ["#blitz__bujuedechuangzuoyu_recorder"] = "灵感喷泉",
  ["#blitz__xuanlanjixingxiu_recorder"] = "群青跃动",
  ["@blitz__Ayla-turn"] = "万华",
  ["@adaptation-turn"] = "随变:",

  ["$blitz__bujuedechuangzuoyu1"] = "“艾拉流”的精髓，体会到了吗？",
  ["$blitz__bujuedechuangzuoyu2"] = "想象力，在此共鸣！",
  ["$blitz__xuanlanjixingxiu1"] = "突发奇想的一笔！",
  ["$blitz__xuanlanjixingxiu2"] = "用这份色彩，重漆未来！",
  ["~blitz__Ayla"] = "凋零的画面……貌似也不错……",
} --艾拉·万华(完成)

local blitz__renyizai = fk.CreateTriggerSkill{
  name = "blitz__renyizai",
  events = {fk.EventPhaseStart, fk.DamageCaused},
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
    return player:hasSkill(self) and target.phase == Player.Play and target == player
    elseif event == fk.DamageCaused then
    return player:hasSkill(self) and target == player and data.card and table.contains(data.card.skillNames, "blitz__renyizai")
    and data.to and table.every(player.room.alive_players, function (p) return p:getHandcardNum() <= data.to:getHandcardNum() end)
    and (data.to:getHandcardNum() + #data.to:getCardIds(Player.Equip)) >= 2
    end
  end,
  on_cost = function (self, event, target, player, data)
    if event == fk.EventPhaseStart then
    local success, dat = player.room:askForUseViewAsSkill(player, "blitz__renyizai_viewas", "#blitz__renyizai:", true, {bypass_times = true})
    if success then
      self.cost_data = dat
      return true
    end
  elseif event == fk.DamageCaused then
    return player.room:askForSkillInvoke(player, self.name, nil, "#blitz__renyizai-invoke")
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
    local dat = self.cost_data
    local card = Fk.skills["blitz__renyizai_viewas"]:viewAs(dat.cards)
    local use = {from = player.id, tos = table.map(dat.targets, function(p) return {p} end), card = card, extraUse = true}
    room:useCard(use)
  elseif event == fk.DamageCaused then
    local cards = room:askForCardsChosen(player, data.to, 2, 2, "he", self.name)
    room:obtainCard(player, {cards}, false, fk.ReasonPrey, player.id ,self.name)
    return true
    end
  end,
}
local blitz__renyizai_viewas = fk.CreateViewAsSkill{
  name = "blitz__renyizai_viewas",
  card_num = 1,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).color == Card.Black
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard("daggar_in_smile")
    card:addSubcard(cards[1])
    card.skillName = "blitz__renyizai"
    return card
  end,
}
local blitz__yuxihe = fk.CreateTriggerSkill{
  name = "blitz__yuxihe",
  events = {fk.EventPhaseStart, fk.TurnEnd},
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
    return player:hasSkill(self) and target.phase == Player.Start and target:isWounded() and target ~= player
    elseif event == fk.TurnEnd then
    return player:hasSkill(self) and player:getMark("blitz__yuxihe-turn") ~= 0 and not target.dead
    end
  end,
  on_cost = function (self, event, target, player, data)
    if event == fk.EventPhaseStart then
    local card = player.room:askForCard(player, 1, 1, true, self.name, true, ".|.|heart", "#blitz__yuxihe_ask:")
    if #card > 0 then
      self.cost_data = card
      return true
    end
  elseif event == fk.TurnEnd then
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
    room:setPlayerMark(player, "blitz__yuxihe-turn", Fk:getCardById(self.cost_data[1]):getTypeString())
   -- room:addTableMarkIfNeed(player, "blitz__yuxihe-turn", Fk:getCardById(self.cost_data[1]).type)
    room:obtainCard(target, self.cost_data, false, fk.ReasonGive)
  elseif event == fk.TurnEnd then
    local pattern = ".|.|.|.|.|"..player:getMark("blitz__yuxihe-turn")..""
    local back = room:askForCard(target, 1, 1, true, self.name, true, pattern, "#blitz__yuxihe_back::"..player.id)
    if #back > 0 then
    room:obtainCard(player, back, false, fk.ReasonGive)
    else
      local x = target:getHandcardNum() - 1
    if x > 0 then
      room:askForDiscard(target, x, x, false, self.name, false)
    elseif x < 0 then
      target:drawCards(1, self.name)
    end
    end
    end
  end,
}
Fk:addSkill(blitz__renyizai_viewas)
Sampo:addSkill(blitz__renyizai)
Sampo:addSkill(blitz__yuxihe)
Fk:loadTranslationTable{
  ["blitz__Sampo"] = "桑博", 
  ["#blitz__Sampo"] = "买卖不成",
  ["cv:blitz__Sampo"] = "刘圣博",
  ["illustrator:blitz__Sampo"] = "YVESKI",
  ["designer:blitz__Sampo"] = "信浓shinano",

  ["blitz__renyizai"] = "仁义在",
  [":blitz__renyizai"] = "出牌阶段开始时，你可以将一张黑色牌当【笑里藏刀】使用。你因此造成伤害时，若目标角色手牌数为全场最多，你可以改为获得其两张牌。",
  ["blitz__yuxihe"] = "予戏盒",
  [":blitz__yuxihe"] = "其他角色的准备阶段，若其已受伤，你可以交给其一张红桃牌。若如此做，本回合结束后，其选择一项：1.交给你一张与此牌类型相同的牌；2.调整手牌数至1。",
  ["blitz__yuxihe-turn"] = "予戏盒",
  ["#blitz__renyizai"] = "仁义在：是否将一张黑色牌当【笑里藏刀】使用？",
  ["blitz__renyizai_viewas"] = "仁义在",
  ["#blitz__renyizai-invoke"] = "是否防止伤害，改为获得其两张牌？",
  ["#blitz__yuxihe_ask"] = "予戏盒：是否将一张红桃牌交给当前回合角色，并在本回合结束后触发后续效果？",
  ["#blitz__yuxihe_back"] = "予戏盒：将一张指定类型的牌交给 %dest ，否则调整手牌至一张。",

  ["$blitz__renyizai1"] = "我桑博一向关照朋友。",
  ["$blitz__renyizai2"] = "又有生意上门了。",
  ["$blitz__renyizai3"] = "你在期待些什么？",
  ["$blitz__renyizai4"] = "顾客就是上帝，想要我背叛上帝，除非…你加钱~",
  ["$blitz__yuxihe1"] = "我坚信，人与人之间美好的感情都是聊出来的。",
  ["$blitz__yuxihe2"] = "买家要什么，我就卖什么，结果他们说我是骗子，你说气不气人……",
  ["~blitz__Sampo"] = "这下…赔大了。",
} --桑博(完成)

local function isPrime(n)
  if n < 2 then
    return false
  end
  for i = 2, math.sqrt(n) do
    if n % i == 0 then
      return false
    end
  end
  return true
end
local blitz__shengzhi = fk.CreateTriggerSkill{
  name = "blitz__shengzhi",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player.dead or not player:hasSkill(self) then return false end
    local number
    local x = 0
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
            number = Fk:getCardById(info.cardId).number
            if isPrime(number) == true then
              player.room:addPlayerMark(player, "@blitz__shengzhicount-turn", 1)
              if player:getMark("@blitz__shengzhicount-turn") % 2 ~= 0 then
              return true
              end
            end
          end
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(2, self.name)
    room:setPlayerMark(player, "@@blitz__shengzhi-turn", 1)
  end,
}
local blitz__shengzhi_prohibit = fk.CreateProhibitSkill{
  name = "#blitz__shengzhi_prohibit",
  prohibit_use = function(self, from, card)
    if from:getMark("@@blitz__shengzhi-turn") > 0 and card then
      if card:isVirtual() then
        if #card.subcards == 0 then
          return false
        else
          return table.find(card.subcards, function (id)
            return isPrime(Fk:getCardById(id).number) == false
          end)
        end
      else
        return isPrime(card.number) == false
      end
    end
  end,
}
local blitz__qiongli = fk.CreateTriggerSkill{
  name = "blitz__qiongli",
  anim_type = "offensive",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and isPrime(player:getHandcardNum()) == true then
      for _, move in ipairs(data) do
        if move.to == player.id and move.toArea == Player.Hand and move.moveReason == fk.ReasonDraw then
          return true
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(5)
    player:showCards(cards)
    local numcards = room:askForCard(player, 2, 2, true, self.name, true, ".", "#blitz__qiongli:")
    if #numcards == 2 then
      local n1 = Fk:getCardById(numcards[1]).number
      local n2 = Fk:getCardById(numcards[2]).number
      if n1 > n2 then
        n1, n2 = n2, n1
      end
      local n3 = n1 + 1
      local n4 = n2 - 1
      local pattern = ".|" .. n3 .. "~".. n4 .. "|.|^(hand,equip,judge)"
      local c = room:askForCard(player, 1, 1, false, self.name, true, pattern, "#blitz__qiongli-await:::".. n3 .. ":" .. n4, cards)
      if #c == 1 then
        room:moveCards({
          ids = c,
          to = player.id,
          toArea = Card.PlayerHand,
          moveReason = fk.ReasonPrey,
          proposer = player.id,
          skillName = self.name,
        })
        room:throwCard(numcards, self.name, player, player)
      end
    end
  end,
}
blitz__shengzhi:addRelatedSkill(blitz__shengzhi_prohibit)
Thirty_Seven:addSkill(blitz__shengzhi)
Thirty_Seven:addSkill(blitz__qiongli)

Fk:loadTranslationTable{
  ["blitz__Thirty_Seven"] = "37", 
  ["#blitz__Thirty_Seven"] = "赫尔墨斯之星",
  ["cv:blitz__Thirty_Seven"] = "Emily Stranges",
  ["illustrator:blitz__Thirty_Seven"] = "深蓝互动",
  ["designer:blitz__Thirty_Seven"] = "白板若此",

  ["blitz__shengzhi"] = "圣质",
  [":blitz__shengzhi"] = "锁定技，你每回合第奇数次失去质数牌后，你摸两张牌，然后你本回合只能使用质数牌。",
  ["blitz__qiongli"] = "穷理",
  [":blitz__qiongli"] = "你因摸牌得到牌后，若你的手牌数为质数，你依次执行直至未执行：展示牌堆顶五张牌；选择两张牌；可以获得一张展示牌；弃置选择的两张牌（获得的牌点数需在弃置牌的点数之间）。",
  ["@@blitz__shengzhi-turn"] = "禁用非质数",
  ["@blitz__shengzhicount-turn"] = "失去质数",
  ["#blitz__qiongli"] = "穷理：是否选择两张牌弃置，然后获得一张点数在两张弃置牌之间的展示牌获得。",
  ["#blitz__qiongli-await"] = "穷理：请选择牌堆顶展示牌中一张点数在%arg与%arg2之间的牌获得。",

  ["$blitz__shengzhi1"] = "Form, space, and order.（空间的形式。）",
  ["$blitz__shengzhi2"] = "The golden ratio!（黄金比例！）",
  ["$blitz__shengzhi3"] = "Fly, my numerical friends!（数字伙伴。）",
  ["$blitz__qiongli1"] = "Fluidity and fluctuation—a hypothesis of Truth.（流动与变化，真理的另一种假设。）",
  ["$blitz__qiongli2"] = "From beneath the water, the answer surfaces ...（答案跃于水面……）",
  ["$blitz__qiongli3"] = "The connection between numbers.（数量的关系。）",
  ["~blitz__Thirty_Seven"] = "Irrational!（无理！）",
} --37(完成)

local isNormalDamage = function(data) -- 讲个笑话，傅肜可以传伤害来源的数据，停云传不了致命伤害属性的数据...
if data.damageType then
  if data.damageType == fk.NormalDamage then
      return true
    end
  end
  local room = data.to.room---@type Room
  local currentEvent = room.logic:getCurrentEvent()
  local damageEvent = currentEvent:findParent(GameEvent.Damage)
  if not damageEvent then return false end
  local id = currentEvent.id - 1
  local lastEvent
  while id > damageEvent.id do
    local e = room.logic.all_game_events[id]
    if not e then break end
    if e.parent == damageEvent then
      lastEvent = e
      break
    end
    id = id - 1
  end
  if lastEvent and lastEvent.event == GameEvent.Damage and lastEvent.data[1].type == fk.NormalDamage then
    return true
  end
  return false
end
local blitz__yidao = fk.CreateActiveSkill{
  name = "blitz__yidao",
  anim_type = "support",
  prompt = "#blitz__yidao_use",
  min_card_num = 0,
  min_target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards)
    local card = Fk:cloneCard("await_exhausted")
    return to_select == Self.id or table.contains(selected, Self.id) and not Self:isProhibited(Fk:currentRoom():getPlayerById(to_select), card)
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:useVirtualCard("await_exhausted", effect.cards, player,
    table.map(effect.tos, Util.Id2PlayerMapper), self.name)
    local x = player:getHandcardNum()
    local y = 0
    for _, p in ipairs(effect.tos) do
      if room:getPlayerById(p):getHandcardNum() == x and not room:getPlayerById(p).dead then
        y = y + 1
      end
    end
    player:drawCards(y, self.name)
  end,
}
local blitz__fenli = fk.CreateTriggerSkill{
  name = "blitz__fenli",
  anim_type = "control",
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return not player.dead and player:hasSkill(self) and player == target and data.damage and target.hp < 1
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local propmt
    local damageEvent = player.room.logic:getCurrentEvent():findParent(GameEvent.Damage)
    if damageEvent then
    if isNormalDamage(damageEvent.data[1]) then
      propmt = "#blitz__fenli_1"
    else
      propmt = "#blitz__fenli_2"
    end
    end
    local to = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
    propmt, self.name, true)
    if #to > 0 then
    self.cost_data = {tos = to}
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    local mapper = {
      ["h"] = Card.PlayerHand,
      ["e"] = Card.PlayerEquip,
      ["j"] = Card.PlayerJudge,
    }
    if data.damage then
      local damageEvent = player.room.logic:getCurrentEvent():findParent(GameEvent.Damage)
      if damageEvent then
    if isNormalDamage(damageEvent.data[1]) then
    local choices = {"blitz__fenli_j", "blitz__fenli_e", "blitz__fenli_h"}
    local choice = room:askForChoice(player, choices, self.name, "#blitz__fenli::"..to.id)
    if choice == "blitz__fenli_j" then
    U.swapCards(room, player, player, to, player:getCardIds("j"), to:getCardIds("j"), self.name,
    mapper["j"])
    elseif choice == "blitz__fenli_e" then
    U.swapCards(room, player, player, to, player:getCardIds("e"), to:getCardIds("e"), self.name,
    mapper["e"])
    elseif choice == "blitz__fenli_h" then
    U.swapCards(room, player, player, to, player:getCardIds("h"), to:getCardIds("h"), self.name,
    mapper["h"])
    end
    else
      --顺序暂定为嚣翻清理区域内牌的顺序
      U.swapCards(room, player, player, to, player:getCardIds("j"), to:getCardIds("j"), self.name,
        mapper["j"])
      U.swapCards(room, player, player, to, player:getCardIds("e"), to:getCardIds("e"), self.name,
        mapper["e"])
      U.swapCards(room, player, player, to, player:getCardIds("h"), to:getCardIds("h"), self.name,
        mapper["h"])
    end
    end
    end
  end,


}
Tingyun:addSkill(blitz__yidao)
Tingyun:addSkill(blitz__fenli)

Fk:loadTranslationTable{
  ["blitz__Tingyun"] = "停云", 
  ["#blitz__Tingyun"] = "绥绥狐魅",
  ["cv:blitz__Tingyun"] = "蒋丽",
  ["illustrator:blitz__Tingyun"] = "崩坏：星穹铁道",
  ["designer:blitz__Tingyun"] = "懵萌猛梦",

  ["blitz__yidao"] = "仪祷",
  [":blitz__yidao"] = "出牌阶段限一次，你可以对包括你在内的任意名角色视为使用【以逸待劳】，然后你摸X张牌（X为与你手牌数相同的目标数）。",
  ["blitz__fenli"] = "焚离",
  [":blitz__fenli"] = "你因普通/属性伤害进入濒死时，你可以与一名其他角色交换一个任意区域/每个区域的所有牌。",
  ["#blitz__yidao_use"] = "使用 仪祷，请先选择你，再选择任意名其他角色，视为对这些角色使用【以逸待劳】。",
  ["#blitz__fenli_1"] = "焚离：你因普通伤害进入濒死，可以与一名其他角色交换一个你选择的区域的所有牌。",
  ["#blitz__fenli_2"] = "焚离：你因属性伤害进入濒死，可以与一名其他角色交换每个区域的所有牌。",
  ["#blitz__fenli"] = "焚离：选择与 %dest 交换所有牌的区域。",
  ["blitz__fenli_h"] = "交换手牌区",
  ["blitz__fenli_e"] = "交换装备区",
  ["blitz__fenli_j"] = "交换判定区",

  ["$blitz__yidao1"] = "就以奇珍万千，给各位鼓劲啦~",
  ["$blitz__yidao2"] = "百事贞吉，一心同归。",
  ["$blitz__fenli1"] = "一彼一此，世事已然改换。",
  ["$blitz__fenli2"] = "前尘隔海，旧我不再。",
  ["~blitz__Tingyun"] = "时运…不济啊…",
} --停云(完成)

local blitz__baizi = fk.CreateTriggerSkill{
  name = "blitz__baizi",
  anim_type = "special",
  frequency = Skill.Compulsory,
  events = {fk.DamageCaused, fk.DamageInflicted, fk.AfterCardUseDeclared},
  can_trigger = function(self, event, target, player, data)
    local mark = player:getTableMark("@blitz__baizi")
    if event == fk.DamageCaused or event == fk.DamageInflicted then
    return target == player and player:hasSkill(self) and table.contains(mark, "diamond")
  elseif event == fk.AfterCardUseDeclared then
    return target == player and player:hasSkill(self) and table.contains(mark, "club")
    and data.card.suit ~= Card.Club
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    if event == fk.DamageCaused or event == fk.DamageInflicted then
      data.damage = data.damage + 1
    elseif event == fk.AfterCardUseDeclared then
      player:drawCards(2, self.name)
      end
  end,
}
local blitz__baizi_delay = fk.CreateTriggerSkill{
  name = "#blitz__baizi_delay",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(blitz__baizi, true)
  end,
  on_use = function(self, event, target, player, data)
    local mark = player:getTableMark("@blitz__baizi")
    for _, id in ipairs(mark) do
      table.removeOne(mark, id)
    end
    table.insertIfNeed(mark, data.card:getSuitString())
    player.room:setPlayerMark(player, "@blitz__baizi", mark)
    if data.card.suit == Card.Spade then
      player.room:setPlayerMark(player, "blitz__baizi-turn", 1)
    end
  end,
}
local blitz__baizi_invalidity = fk.CreateInvaliditySkill {
  name = "#blitz__baizi_invalidity",
  invalidity_func = function(self, from, skill)
    return skill == blitz__baizi and from:getMark("blitz__baizi-turn") == 1
  end
}
local blitz__qianyi = fk.CreateTriggerSkill{
  name = "blitz__qianyi",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardUseDeclared},
  can_trigger = function(self, event, target, player, data)
    return player == target and player:hasSkill(self) and data.card.suit == Card.Spade
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local all = player:getTableMark("@blitz__qianyi-turn")
    local all_choices = {"log_club", "log_heart", "log_diamond"}
    local choices = {}
    for _, id in ipairs(all) do
      table.insertIfNeed(choices, id)
    end
    if #choices == 0 then
      self.cost_data = nil
      return true
    else
     local choice = room:askForChoice(player, choices, self.name, "#blitz__jingce_suit:", nil, all_choices)
     self.cost_data = choice
     return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local suit_log = self.cost_data
    if not suit_log or suit_log == nil then
      player.room:setPlayerMark(player, "blitz__qianyi-turn", 1)
      return false end
    local card_suits_reverse_table = {
      log_spade = 1,
      log_club = 2,
      log_heart = 3,
      log_diamond = 4,
    }
    local suit = card_suits_reverse_table[suit_log]
      local card = Fk:cloneCard(data.card.name, data.card.suit, data.card.number)
      for k, v in pairs(data.card) do
        if card[k] == nil then
          card[k] = v
        end
      end
      if data.card:isVirtual() then
        card.subcards = data.card.subcards
      else
        card.id = data.card.id
      end
      card.skillNames = data.card.skillNames
      card.skillName = "blitz__qianyi"
      card.suit = suit
      if suit == Card.Diamond or suit == Card.Heart then
      card.color = Card.Red
      elseif suit == Card.Club or suit == Card.Spade then
      card.color = Card.Black
      end
      data.card = card
  end,
}
local blitz__qianyi_trigger = fk.CreateTriggerSkill{
  name = "#blitz__qianyi_trigger",
  mute = true,
  refresh_events = {fk.CardUsing, fk.TurnStart}, --统一记牌器时机为使用牌时算了
  can_refresh = function(self, event, target, player, data)
    if event == fk.CardUsing then
    return target == player and player:hasSkill("blitz__qianyi", true) and data.card.suit ~= Card.NoSuit
  elseif event == fk.TurnStart then
    return player:hasSkill("blitz__qianyi", true)
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local mark = player:getTableMark("@blitz__qianyi-turn")
    if event == fk.CardUsing then
      table.removeOne(mark, data.card:getSuitString(true))
      player.room:setPlayerMark(player, "@blitz__qianyi-turn", #mark > 0 and mark or 0)
    elseif event == fk.TurnStart then
      table.insertIfNeed(mark, "log_heart")
      table.insertIfNeed(mark, "log_diamond")
      table.insertIfNeed(mark, "log_club")
      player.room:setPlayerMark(player, "@blitz__qianyi-turn", mark)
    end
  end,

  on_acquire = function (self, player, is_start)
      local room = player.room
      local mark = {"log_heart", "log_diamond" ,"log_club"}
      room:setPlayerMark(player, "@blitz__qianyi-turn", mark)
      room.logic:getEventsOfScope(GameEvent.UseCard, 999, function (e)
        local use = e.data[1]
        if use.from == player.id and use.card.suit ~= Card.NoSuit then
          table.removeOne(mark, use.card:getSuitString(true))
        end
      end, Player.HistoryTurn)
      room:setPlayerMark(player, "@blitz__qianyi-turn", #mark > 0 and mark or 0)
  end,
}
local blitz__qianyi_invalidity = fk.CreateInvaliditySkill {
  name = "#blitz__qianyi_invalidity",
  invalidity_func = function(self, from, skill)
    return skill == blitz__qianyi and from:getMark("blitz__qianyi-turn") == 1
  end
}
local blitz__shenglin = fk.CreateActiveSkill{
  name = "blitz__shenglin",
  anim_type = "drawcard",
  prompt = function(self)
    if Self:hasSkill("blitz__baizi") or Self:hasSkill("blitz__qianyi") then
    return "#blitz__shenglin1"
    else
    return "#blitz__shenglin2"
    end
  end,
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 1
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local mark = player:getTableMark("@blitz__shenglin-turn")
      player:drawCards(3, self.name)
      table.insertIfNeed(mark, "blitz__shenglin_hit")
      if player:hasSkill("blitz__baizi") or player:hasSkill("blitz__qianyi") then
      table.insertIfNeed(mark, "blitz__shenglin_lose")
      end
    room:setPlayerMark(player, "@blitz__shenglin-turn", #mark > 0 and mark or 0)
  end,
}
local blitz__shenglin_trigger = fk.CreateTriggerSkill{
  name = "#blitz__shenglin_trigger",
  mute = true,
  events = {fk.DamageCaused, fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    if event == fk.DamageCaused then
    return target == player and table.contains(player:getTableMark("@blitz__shenglin-turn"), "blitz__shenglin_hit")
    elseif event == fk.EventPhaseEnd then
    return target == player and table.contains(player:getTableMark("@blitz__shenglin-turn"), "blitz__shenglin_lose")
    and player.phase == Player.Finish
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageCaused then
    player:broadcastSkillInvoke("blitz__shenglin")
    room:notifySkillInvoked(player, "blitz__shenglin")
    data.damage = data.damage + 1
  elseif event == fk.EventPhaseEnd then
    player:broadcastSkillInvoke("blitz__shenglin")
    room:notifySkillInvoked(player, "blitz__shenglin")
    room:loseHp(player, player.hp, self.name)
  end
  end,
}
blitz__baizi:addRelatedSkill(blitz__baizi_delay)
blitz__baizi:addRelatedSkill(blitz__baizi_invalidity)
blitz__qianyi:addRelatedSkill(blitz__qianyi_trigger)
blitz__qianyi:addRelatedSkill(blitz__qianyi_invalidity)
blitz__shenglin:addRelatedSkill(blitz__shenglin_trigger)
The_Watcher:addSkill(blitz__baizi)
The_Watcher:addSkill(blitz__qianyi)
The_Watcher:addSkill(blitz__shenglin)

Fk:loadTranslationTable{
  ["blitz__The_Watcher"] = "观者", 
  ["#blitz__The_Watcher"] = "渡尘兰袍",
  ["cv:blitz__The_Watcher"] = "暂无",
  ["illustrator:blitz__The_Watcher"] = "杀戮尖塔",
  ["designer:blitz__The_Watcher"] = "莫许诺",

  ["blitz__baizi"] = "百姿",
  [":blitz__baizi"] = "锁定技，若你使用的上一张牌的花色为:◆--你受到和造成的伤害+1；♣--你使用非♣牌时，摸两张牌;♠--本回合“百姿”失效。",
  ["blitz__qianyi"] = "虔仪",
  [":blitz__qianyi"] = "锁定技。你使用♠牌时，将花色改为你本回合未使用过的其他花色，否则本回合“虔仪”失效。",
  ["blitz__shenglin"] = "圣临",
  [":blitz__shenglin"] = "出牌阶段限一次，你可以摸三张牌并令本回合你造成的伤害+1，然后若你武将牌上其他技能不均无效，结束阶段你失去所有体力。",
  ["@blitz__baizi"] = "百姿",
  ["@blitz__qianyi-turn"] = "虔仪",
  ["#blitz__jingce_suit"] = "发动 虔仪，请修改此牌花色。",
  ["@blitz__shenglin-turn"] = "圣临",
  ["#blitz__shenglin_trigger"] = "圣临",
  ["blitz__shenglin_hit"] = "加伤",
  ["blitz__shenglin_lose"] = "崩血",
  ["#blitz__shenglin1"] = "发动 圣临，摸三张牌且本回合加伤，结束阶段失去所有体力。",
  ["#blitz__shenglin2"] = "发动 圣临，摸三张牌且本回合加伤。",

  ["~blitz__The_Watcher"] = "…",
} --观者(完成)

local blitz__xunri = fk.CreateTriggerSkill{
  name = "blitz__xunri",
  anim_type = "offensive",
  events = {fk.TurnEnd, fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if event == fk.TurnEnd then
    return player:hasSkill(self) and target.hp >= player.hp
    and player:canUseTo(Fk:cloneCard("fire_attack"), target, { bypass_times = true, bypass_distances= true })
    elseif event == fk.CardUseFinished then
    return not player.dead and table.contains(data.card.skillNames, "blitz__xunri")
    and data.extra_data and data.extra_data.blitzxunriUser == player.id
    and table.find(TargetGroup:getRealTargets(data.tos), function(pid)
      return player.room:getPlayerById(pid):canUseTo(Fk:cloneCard("unexpectation"), player, { bypass_times = true, bypass_distances= true })
      and not (data.damageDealt and data.damageDealt[pid]) and not player.room:getPlayerById(pid).dead
     end)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TurnEnd then
    return true
    elseif event == fk.CardUseFinished then
    for _, pid in ipairs(TargetGroup:getRealTargets(data.tos)) do
    local to = room:getPlayerById(pid)
    return room:askForSkillInvoke(to, self.name, nil, "#blitz__xunri")
    end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TurnEnd then
    local fire_attack = Fk:cloneCard("fire_attack")
    fire_attack.skillName = "blitz__xunri"
    if player:canUseTo(fire_attack, target, { bypass_times = true, bypass_distances= true }) then
        room:useCard{
          from = player.id,
          card = fire_attack,
          tos = { { target.id } },
          extraUse = true,
          extra_data = { blitzxunriUser = player.id }
     }
    end
    elseif event == fk.CardUseFinished then
      local showMap = data.extra_data and data.extra_data.blitzxunri or {}
      for _, pid in ipairs(TargetGroup:getRealTargets(data.tos)) do
        if player.dead then break end
        local to = room:getPlayerById(pid)
        if not to.dead and showMap[to.id] then
          local cards = showMap[to.id]
          local unexpectation = Fk:cloneCard("unexpectation")
          unexpectation.skillName = "blitz__xunri"
          for _, cardId in ipairs(cards) do
            if table.contains(to:getCardIds("h"), cardId) then
            unexpectation:addSubcard(cardId)  
            room:useCard{
            from = to.id,
            card = unexpectation,
            tos = { { player.id } },
            extraUse = true,
            }
          end
          end
        end
      end
    end
  end,

  refresh_events = {fk.CardShown},
  can_refresh = function(self, event, target, player, data)
    if target == player then
      local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
      if e then
        local use = e.data[1]
        return table.contains(use.card.skillNames, "blitz__xunri")
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    if e then
      local use = e.data[1]
      use.extra_data = use.extra_data or {}
      use.extra_data.blitzxunri = use.extra_data.blitzxunri or {}
      use.extra_data.blitzxunri[player.id] = use.extra_data.blitzxunri[player.id] or {}
      table.insert(use.extra_data.blitzxunri[player.id], data.cardIds[1])
    end
  end,
}
local blitz__chenrui = fk.CreateTriggerSkill{
  name = "blitz__chenrui",
  anim_type = "drawcard",
  events = {fk.CardShown},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self, true)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if target == player then
    return room:askForSkillInvoke(player, self.name, nil, "#blitz__chenrui")
    elseif target ~= player then
    local card = room:askForCard(target, 1, 1, true, self.name, true, ".", "#blitz__chenrui_cost::"..player.id)
    if #card > 0 then
      self.cost_data = card
      return true
  else
    return false
    end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if target ~= player then
    room:obtainCard(player, self.cost_data, false, fk.ReasonGive)
    end
    local card1 = room:askForCard(player, 0, 2, true, self.name, false, ".", "#blitz__chenrui_ask:")
    if #card1 > 0 then
      room:recastCard(card1, player, self.name)
    end
    local card2 = room:askForCard(target, 0, 2, true, self.name, false, ".", "#blitz__chenrui_ask:")
    if #card2 > 0 then
      room:recastCard(card2, target, self.name)
    end
  end,
}
local blitz__buwei = fk.CreateTriggerSkill{
  name = "blitz__buwei",
  anim_type = "offensive",
  events = {fk.TargetConfirming, fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if event == fk.TargetConfirming then
    return target == player and player:hasSkill(self) and data.card.is_damage_card and not player.room:getPlayerById(data.from).dead
  elseif event == fk.DamageInflicted then
    return player:hasSkill(self) and target:getMark("@blitz__buwei-turn") > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetConfirming then
    return  room:askForSkillInvoke(player, self.name, nil, "#blitz__buwei")
    elseif event == fk.DamageInflicted then
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetConfirming then
      room:addPlayerMark(player, "@blitz__buwei-turn" ,1)
      room:addPlayerMark(room:getPlayerById(data.from), "@blitz__buwei-turn" ,1)
    elseif event == fk.DamageInflicted then
      data.damage = data.damage + target:getMark("@blitz__buwei-turn")
    end
  end,
}
Zuole:addSkill(blitz__xunri)
Zuole:addSkill(blitz__chenrui)
Zuole:addSkill(blitz__buwei)
Fk:loadTranslationTable{
  ["blitz__Zuole"] = "左乐", 
  ["#blitz__Zuole"] = "秉烛长明",
  ["cv:blitz__Zuole"] = "李嘉祥",
  ["illustrator:blitz__Zuole"] = "明日方舟",
  ["designer:blitz__Zuole"] = "三根铅笔",

  ["blitz__xunri"] = "巡日",
  [":blitz__xunri"] = "体力值不小于你的角色回合结束时，你视为对其使用一张【火攻】，若未造成伤害，其可以将展示牌当【出其不意】对你使用。",
  ["blitz__chenrui"] = "沉锐",
  [":blitz__chenrui"] = "一名角色展示牌后，其可以交给你一张牌(若为你则跳过)，然后你与其各重铸至多两张牌。",
  ["blitz__buwei"] = "步危",
  [":blitz__buwei"] = "你成为伤害类牌的目标时，你可以令你与此牌使用者本回合受到的伤害+1。",
  ["#blitz__xunri"] = "巡日：是否将展示牌当【出其不意】对对方使用？",
  ["#blitz__chenrui"] = "沉锐：是否重复两次：重铸至多两张牌？",
  ["#blitz__chenrui_cost"] = "沉锐：是否交给 %dest 一张牌，然后与其各重铸至多两张牌？",
  ["#blitz__chenrui_ask"] = "沉锐：请重铸至多两张牌，不选牌确定则跳过。",
  ["#blitz__buwei"] = "步危：是否与此牌使用者本回合受到的伤害+1？",
  ["@blitz__buwei-turn"] = "步危",

  ["$blitz__xunri1"] = "不会遗漏任何风吹草动。",
  ["$blitz__xunri2"] = "各位留步，此路不通！",
  ["$blitz__chenrui1"] = "愿尽绵薄之力。",
  ["$blitz__chenrui2"] = "良才善用，能者居之，左乐当尽全力。",
  ["$blitz__buwei1"] = "刀势无形，别欺它在匣内！",
  ["$blitz__buwei2"] = "你们胆敢造次！",
  ["~blitz__Zuole"] = "兽与厚土行，秉烛入长夜…",
} --左乐(完成)

--- 改变转换技状态 （直接用海外服扩展的吧，考虑到扩展不全很多引用的地方都要非常小心）
---@param room Room
---@param player Player
---@param target Player
---@param reason? string
---@return string @ 被改变的转换技名
local function ChangeSwitchState(room, player, target, reason)
  local skills = table.filter(target.player_skills, function(s)
    return s:isSwitchSkill() 
  end)
  local skillNames = table.map(skills, function(s)
    return s.name
  end)
  local skill = skills[table.indexOf(skillNames, room:askForChoice(player, skillNames, reason, "#blitz__longyizy-ask:" .. target.id))]
  local switchSkillName = skill.switchSkillName
  room:setPlayerMark(
    target,
    MarkEnum.SwithSkillPreName .. switchSkillName,
    target:getSwitchSkillState(switchSkillName, true)
  )
  target:addSkillUseHistory(skill.name) --……
  room:sendLog{
    type = "#ChangeSwitchState",
    from = player.id,
    to = {target.id},
    arg = skill.name,
    arg2 = target:getSwitchSkillState(switchSkillName, false, true),
  }
  return skill.name
end

local blitz__longhun = fk.CreateViewAsSkill{
  name = "blitz__longhun",
  switch_skill_name = "blitz__longhun",
  anim_type = "switch",
  prompt = function ()
    return "#blitz__longhun-viewas"
  end,
  pattern = ".|.|.|.|.|basic",
  interaction = function()
    local all_names = U.getAllCardNames("b")
    return U.CardNameBox {
      choices = U.getViewAsCardNames(Self, "blitz__longhun", all_names),
      all_choices = all_names,
      default_choice = "AskForCardsChosen",
    }
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    if Fk.all_card_types[self.interaction.data] == nil then return nil end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player)
    local room = player.room
    room:setPlayerMark(player, "blitz__longhun-turn", 1)
  end,
  enabled_at_play = function(self, player)
    return player:isKongcheng() and player:getMark("blitz__longhun-turn") == 0 and player:getSwitchSkillState(self.name) == fk.SwitchYin
  end,
  enabled_at_response = function(self, player, response)
    return player:isKongcheng() and player:getMark("blitz__longhun-turn") == 0 and player:getSwitchSkillState(self.name) == fk.SwitchYin
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
    room:setPlayerMark(player, "blitz__longhun-turn", 0)
  end,
}
local blitz__longhunYang = fk.CreateTriggerSkill{
  name = "#blitz__longhunYang",
  switch_skill_name = "blitz__longhun",
  anim_type = "switch",
  main_skill = blitz__longhun,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill("blitz__longhun") then return end

    local isYang = player:getSwitchSkillState("blitz__longhun") == fk.SwitchYang
    if event == fk.EventPhaseStart and isYang then
      return target.phase == Player.Finish and player:getMark("blitz__longhunYang-turn") > 0
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("blitz__longhun")
    player:throwAllCards("h")
    if player:getLostHp() > 0 then
    player:drawCards(player:getLostHp(), self.name)
    end
  end,

  refresh_events = {fk.CardUsing, fk.CardResponding},
  can_refresh = function(self, event, target, player, data)
    return target == player and data.card.type == Card.TypeBasic
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "blitz__longhunYang-turn", 1)
  end,
}
local blitz__longdan = fk.CreateViewAsSkill{
  name = "blitz__longdan",
  pattern = "slash,jink,peach,analeptic",
  handly_pile = true,
  card_filter = function(self, to_select, selected)
    if #selected ~= 0 then return false end
    local _c = Fk:getCardById(to_select)
    local c
    if _c.trueName == "slash" then
      c = Fk:cloneCard("jink")
    elseif _c.name == "jink" then
      c = Fk:cloneCard("slash")
    elseif _c.name == "peach" then
      c = Fk:cloneCard("analeptic")
    elseif _c.name == "analeptic" then
      c = Fk:cloneCard("peach")
    else
      return false
    end
    return (Fk.currentResponsePattern == nil and c.skill:canUse(Self, c)) or
      (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(c))
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then
      return nil
    end
    local _c = Fk:getCardById(cards[1])
    local c
    if _c.trueName == "slash" then
      c = Fk:cloneCard("jink")
    elseif _c.name == "jink" then
      c = Fk:cloneCard("slash")
    elseif _c.name == "peach" then
      c = Fk:cloneCard("analeptic")
    elseif _c.name == "analeptic" then
      c = Fk:cloneCard("peach")
    end
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
}
local blitz__longyizy = fk.CreateTriggerSkill{
  name = "blitz__longyizy",
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    local nameyou
    if Fk:translate(player.general, "zh_CN"):len() > 3 then
      nameyou = Fk:translate(player.general, "zh_CN")[3]
    else
      nameyou = Fk:translate(player.general, "zh_CN")[1]
    end
    return target == player and player:hasSkill(self) and data.card and not U.isPureCard(data.card) and #data.card.subcards > 0
      and table.find(player.room.alive_players, function(p)
      return table.find(p.player_skills, function(s) return s:isSwitchSkill() end) 
      and Fk:translate(p.general, "zh_CN"):len() > 3 and Fk:translate(p.general, "zh_CN")[3] or Fk:translate(p.general, "zh_CN")[1] == nameyou
    end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local nameyou
    if Fk:translate(player.general, "zh_CN"):len() > 3 then
      nameyou = Fk:translate(player.general, "zh_CN")[3]
    else
      nameyou = Fk:translate(player.general, "zh_CN")[1]
    end
    local targets = table.map(table.filter(room.alive_players, function(p)
      return table.find(p.player_skills, function(s) return s:isSwitchSkill() end) 
      and (Fk:translate(p.general, "zh_CN"):len() > 3 and Fk:translate(p.general, "zh_CN")[3] or Fk:translate(p.general, "zh_CN")[1] == nameyou)
    end)
      , Util.IdMapper)
    local to = player.room:askForChoosePlayers(player, targets, 1, 1, "#blitz__longyizy", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end 
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = self.cost_data
    room:doIndicate(player.id, {to})
    ChangeSwitchState(room, player, room:getPlayerById(to), self.name)
  end,
}
blitz__longhun:addRelatedSkill(blitz__longhunYang)
Zhaoyun:addSkill(blitz__longhun)
Zhaoyun:addSkill(blitz__longdan)
Zhaoyun:addSkill(blitz__longyizy)
Fk:loadTranslationTable{
  ["blitz__Zhaoyun"] = "赵云", 
  ["#blitz__Zhaoyun"] = "不灭之龙",
  ["cv:blitz__Zhaoyun"] = "官方",
  ["illustrator:blitz__Zhaoyun"] = "白",
  ["designer:blitz__Zhaoyun"] = "想去远方",

  ["blitz__longhun"] = "龙魂",
  [":blitz__longhun"] = "转换技，阳：你使用或打出基本牌后，本回合结束阶段你弃置所有手牌，摸已损失体力值张牌；"..
  "阴：每回合限一次，若你没有手牌，你可以视为使用或打出基本牌。",
  ["#blitz__longhunYang"] = "龙魂",
  ["blitz__longdan"] = "龙胆",
  [":blitz__longdan"] = "你可以将一张【杀】当【闪】、【闪】当【杀】、【酒】当【桃】、【桃】当【酒】使用或打出。",
  ["blitz__longyizy"] = "龙裔",
  [":blitz__longyizy"] = "宗族技，你使用转化牌时，你可以改变一名同姓角色阴阳转换技的状态。",
  ["#blitz__longhun-viewas"] = "龙魂：您已空城，可以视为或打出任意基本牌。",
  ["#blitz__longyizy-ask"] = "龙裔：你可选择 %src 的一个转换技，调整其阴阳状态",
  ["#blitz__longyizy"] = "龙裔：你可选择有转换技的一名同姓角色（主副将有同名均可），调整其一个转换技阴阳状态。",

  ["$blitz__longdan1"] = "龙翔九天，曳日月于天地，换旧符于新岁。",
  ["$blitz__longdan2"] = "御风万里，辟邪祟于宇外，映祥瑞于神州。",
  ["$blitz__longyizy1"] = "龙诞新岁，普天同庆，魂佑宇内，裔泽炎黄。",
  ["$blitz__longyizy2"] = "龙吐息而万物生，今龙临神州，华夏当兴！",
  ["$blitz__longhun1"] = "八尺之身，秉义承武，胸腹可栖万丈苍龙。",
  ["$blitz__longhun2"] = "左执青釭，右擎龙胆，此天下，可有挡我者。",
  ["~blitz__Zhaoyun"] = "亢龙有悔，恨未除天狼于人间……",
} --赵云（完成）

local blitz__jinfan = fk.CreateViewAsSkill{
  name = "blitz__jinfan",
  anim_type = "support",
  pattern = "slash",
  prompt = function(self)
    local cards = Self.player_cards[Player.Hand]
    local y = 0
      for _, id in ipairs(cards) do
        if Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len() > y then
        y = Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len()
        end
      end
    local x = 4 - #Self:getTableMark("blitz__jinfan-turn")
    if self.interaction.data == "blitzCentral" then
      return "#blitz__jinfan1:::"..x
    elseif self.interaction.data == "blitzTwo" then
      return "#blitz__jinfan2"
    elseif self.interaction.data == "blitzLength" then
      return "#blitz__jinfan3:::"..y
    end
  end,
  interaction = function()
    local cards = Self.player_cards[Player.Hand]
    local y = 0
      for _, id in ipairs(cards) do
        if Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len() > y then
        y = Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len()
        end
      end
    local x = 4 - #Self:getTableMark("blitz__jinfan-turn")
    local choices, all_choices = {}, {"blitzCentral", "blitzTwo", "blitzLength"}
    local mark = Self:getTableMark("@blitz__jinfan")
    for _, id in ipairs(mark) do
      table.insertIfNeed(choices, id)
    end
    if x ~= 1 and Self:getHandcardNum() < x then
      table.removeOne(choices, "blitzCentral")
    end
    --判断一下是不是只有甘宁有手牌且不足两张，且其他人装备都没有了，根据设计本意这个情况是不可以适用不足全弃的
    if (Self:getHandcardNum() < 2 and Self:getHandcardNum() > 0 and #table.filter(Fk:currentRoom().alive_players,
    function (p) return not p:isNude() end) <= 1 ) or (Self:getHandcardNum() == 0 and #Self:getCardIds(Player.Equip) == 0 and
    #table.filter(Fk:currentRoom().alive_players, function (p) return not p:isNude() end) == 0 )
    or (Self:getHandcardNum() == 0 and #Self:getCardIds(Player.Equip) > 0 and
    #table.filter(Fk:currentRoom().alive_players, function (p) return not p:isNude() end) <= 1 ) then
      table.removeOne(choices, "blitzTwo")
    end
    if y ~= 3 and Self:getHandcardNum() < y then
      table.removeOne(choices, "blitzLength")
    end
    return UI.ComboBox {choices = choices, all_choices = all_choices}
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard("slash")
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local cards = player.player_cards[Player.Hand]
    local y = 0
      for _, id in ipairs(cards) do
        if Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len() > y then
        y = Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len()
        end
      end
    local x = 4 - #player:getTableMark("blitz__jinfan-turn")
    local targets = {}
    for _, p in ipairs(player.room:getAlivePlayers()) do
      if (p ~= player and not p:isNude()) or (self.interaction.data == "blitzCentral" and p:getHandcardNum() >= x ) 
      or (self.interaction.data == "blitzTwo" and p:getHandcardNum() >= 2 )
      or (self.interaction.data == "blitzLength" and p:getHandcardNum() >= y )then
        table.insert(targets, p.id)
      end
    end
    if #targets == 0 and not (self.interaction.data == "blitzCentral" and x == 0)
    and not (self.interaction.data == "blitzLength" and y == 0) then return "" end
    if self.interaction.data == "blitzCentral" then
      local mark = player:getTableMark("@blitz__jinfan")
      table.removeOne(mark, "blitzCentral")
      room:setPlayerMark(player, "@blitz__jinfan", #mark > 0 and mark or 0)
    if x ~= 1 then
      room:askForDiscard(player, x, x, false, self.name, false)
    else
      if #targets == 0 then return "" end
      local tos = room:askForChoosePlayers(player, targets, 1, 1, "#jinfan__blitzCentral-choose:::"..x, self.name, false)
      local to = room:getPlayerById(tos[1])
      if to ~= player then
      room:askForDiscard(to, 1, 1, true, self.name, false)
      else
      room:askForDiscard(to, 1, 1, false, self.name, false)
      end
    end
    elseif self.interaction.data == "blitzTwo" then
      local mark = player:getTableMark("@blitz__jinfan")
      table.removeOne(mark, "blitzTwo")
      room:setPlayerMark(player, "@blitz__jinfan", #mark > 0 and mark or 0)
      if #targets == 0 then return "" end
      local tos = room:askForChoosePlayers(player, targets, 1, 1, "#jinfan__blitzTwo-choose", self.name, false)
      local to = room:getPlayerById(tos[1])
      if to ~= player then
      room:askForDiscard(to, 2, 2, true, self.name, false)
      else
      room:askForDiscard(to, 2, 2, false, self.name, false)
      end
    elseif self.interaction.data == "blitzLength" then
      local mark = player:getTableMark("@blitz__jinfan")
      table.removeOne(mark, "blitzLength")
      room:setPlayerMark(player, "@blitz__jinfan", #mark > 0 and mark or 0)
      if y ~= 3 then
        room:askForDiscard(player, y, y, false, self.name, false)
      else
        if #targets == 0 then return "" end
        local tos = room:askForChoosePlayers(player, targets, 1, 1, "#jinfan__blitzLength-choose:::"..y, self.name, false)
        local to = room:getPlayerById(tos[1])
        if to ~= player then
        room:askForDiscard(to, 3, 3, true, self.name, false)
        else
        room:askForDiscard(to, 3, 3, false, self.name, false)
        end
      end
    end
  end,
  enabled_at_play = function(self, player)
    local cards = player.player_cards[Player.Hand]
    local y = 0
      for _, id in ipairs(cards) do
        if Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len() > y then
        y = Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len()
        end
      end
    local x = 4 - #player:getTableMark("blitz__jinfan-turn")
    return #player:getTableMark("@blitz__jinfan") > 0 and (x == 0 or y == 0 or (x ~= 0 and y ~= 0 and
    table.find(Fk:currentRoom().alive_players, function (p) return not p:isNude() end)))
  end,
  enabled_at_response = function(self, player, response)
    local cards = player.player_cards[Player.Hand]
    local y = 0
      for _, id in ipairs(cards) do
        if Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len() > y then
        y = Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len()
        end
      end
    local x = 4 - #player:getTableMark("blitz__jinfan-turn")
    return #player:getTableMark("@blitz__jinfan") > 0 and not response and Fk.currentResponsePattern and
    Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("slash")) and (x == 0 or y == 0 or (x ~= 0 and y ~= 0 and
    table.find(Fk:currentRoom().alive_players, function (p) return not p:isNude() end)))
  end,

  on_acquire = function (self, player, is_start)
    player.room:setPlayerMark(player, "@blitz__jinfan", {"blitzCentral", "blitzTwo", "blitzLength"})
  end,
  on_lose = function (self, player, is_death)
    local room = player.room
    room:setPlayerMark(player, "@blitz__jinfan", 0)
  end,
}
local blitz__jinfan_refresh = fk.CreateTriggerSkill{
  name = "#blitz__jinfan_refresh",

  refresh_events = {fk.AfterCardsMove, fk.EventAcquireSkill},
  can_refresh = function(self, event, target, player, data)
    if event == fk.AfterCardsMove then
      for _, move in ipairs(data) do
        if move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
            if player.room:getCardArea(info.cardId) == Card.DiscardPile and Fk:getCardById(info.cardId).suit ~= Card.NoSuit then
              return true
            end
          end
        end
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.DiscardPile and player.room:getCardArea(info.cardId) ~= Card.DiscardPile then
            return true
          end
        end
      end
    else
      return data == self and player.room:getTag("RoundCount")
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.AfterCardsMove then
      local ids = player:getTableMark("blitz__jinfan-turn")
      for _, move in ipairs(data) do
        if move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
            if room:getCardArea(info.cardId) == Card.DiscardPile then
              table.insertIfNeed(ids, Fk:getCardById(info.cardId):getSuitString(true))
            end
          end
        end
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.DiscardPile and room:getCardArea(info.cardId) ~= Card.DiscardPile then
            table.removeOne(ids, Fk:getCardById(info.cardId):getSuitString(true))
          end
        end
      end
      room:setPlayerMark(player, "blitz__jinfan-turn", ids)
    else
      local ids = {}
      room.logic:getEventsOfScope(GameEvent.MoveCards, 999, function(e)
        for _, move in ipairs(e.data) do
          if move.toArea == Card.DiscardPile then
            for _, info in ipairs(move.moveInfo) do
              if room:getCardArea(info.cardId) == Card.DiscardPile then
                table.insertIfNeed(ids, Fk:getCardById(info.cardId):getSuitString(true))
              end
            end
          end
        end
      end, Player.HistoryTurn)
      room:setPlayerMark(player, "blitz__jinfan-turn", ids)
    end
  end,
}
local blitz__sheque = fk.CreateTriggerSkill{
  name = "blitz__sheque",
  anim_type = "offensive",
  events = {fk.Damaged, fk.AfterCardsMove, fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or player:usedSkillTimes(self.name, Player.HistoryRound) >= 1 then return false end
    if event == fk.Damaged then
    return target == player
  elseif event == fk.AfterCardsMove then
    for _, move in ipairs(data) do
      if move.from == player.id and move.to ~= player.id and #move.moveInfo > 1
      and move.moveReason == fk.ReasonDiscard then
        for _, info in ipairs(move.moveInfo) do
          return info.fromArea == Card.PlayerHand
        end
      end
    end
  elseif event == fk.CardUseFinished then
    return target == player and data.card.trueName == "slash"
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
    "#blitz__sheque_0", self.name, true)
    if #tos > 0 then
    self.cost_data = tos[1]
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    if player.dead or to.dead then return false end
    local use = room:askForUseCard(to, "slash", "slash", "#blitz__sheque-slash", true, { bypass_times = true })
    if use then
      use.extraUse = true
      room:useCard(use)
    else
      if player.dead or to.dead then return false end
      local dis = room:askForDiscard(to, 2, 999, false, self.name, true, ".", "#blitz__sheque-dis")
      if #dis > 1 then
        if event == fk.CardUseFinished then
          player:setSkillUseHistory(self.name, 0, Player.HistoryRound)
        end
      else
        if player.dead or to.dead then return false end
        room:damage{
          from = player,
          to = to,
          damage = 1,
          skillName = self.name,
        }
        if event == fk.AfterCardsMove or event == fk.CardUseFinished then
          player:setSkillUseHistory(self.name, 0, Player.HistoryRound)
        end
      end
    end
  end,
}
blitz__jinfan:addRelatedSkill(blitz__jinfan_refresh)
Ganning:addSkill(blitz__jinfan)
Ganning:addSkill(blitz__sheque)
Fk:loadTranslationTable{
  ["blitz__Ganning"] = "甘宁", 
  ["#blitz__Ganning"] = "锦帆游侠",
  ["cv:blitz__Ganning"] = "官方",
  ["illustrator:blitz__Ganning"] = "木美人",
  ["designer:blitz__Ganning"] = "科·戈",

  ["blitz__jinfan"] = "锦帆",
  [":blitz__jinfan"] = "每局每项限一次，你可以弃置对应数量张手牌视为使用【杀】，若所需牌数等于此项序号，你可以改为令其他角色弃置等量张牌。"..
  "①本回合弃牌堆缺少的花色数 ②2 ③手牌中最大牌名字数。",
  ["blitz__sheque"] = "射却",
  [":blitz__sheque"] = "每轮限一次，你执行一项后，你可以令一名其他角色选择执行一项，若你执行项的序号数大于其，复原此技能："..
  "①受到1点伤害 ②弃置至少两张手牌 ③使用一张【杀】。",
  ["@blitz__jinfan"] = "",
  ["blitzCentral"] = "花色",
  ["blitzTwo"] = "2",
  ["blitzLength"] = "字数",
  ["#blitz__jinfan1"] = "本项为第 1 项，弃牌数：%arg ，若两个数字相等，可让其他角色代替你弃牌",
  ["#blitz__jinfan2"] = "本项为第 2 项，弃牌数：2，若两个数字相等，可让其他角色代替你弃牌",
  ["#blitz__jinfan3"] = "本项为第 3 项，弃牌数：%arg ，若两个数字相等，可让其他角色代替你弃牌",
  ["#jinfan__blitzCentral-choose"] = "请令一名角色代替你弃置 %arg 张牌，若为你则仅能弃置此数量的手牌",
  ["#jinfan__blitzTwo-choose"] = "请令一名角色代替你弃置 2 张牌，若为你则仅能弃置此数量的手牌",
  ["#jinfan__blitzLength-choose"] = "请令一名角色代替你弃置 %arg 张牌，若为你则仅能弃置此数量的手牌",
  ["#blitz__sheque_0"] = "射却：是否选择一名其他角色，令其执行出杀/弃牌/受伤效果并有可能刷新本技能？",
  ["#blitz__sheque-slash"] = "射却：是否使用【杀】，或弃至少两张手牌，或受到技能使用者的1点伤害？"..
  "<br>请注意，若技能发动时机为使用牌/弃牌，且你弃牌或受到伤害/受到伤害，本技能将被刷新。",
  ["#blitz__sheque-dis"] = "射却：是否弃至少两张手牌，或受到技能使用者的1点伤害？"..
  "<br>请注意，若技能发动时机为使用牌/弃牌，且你弃牌或受到伤害/受到伤害，本技能将被刷新。",

  ["$blitz__jinfan1"] = "扬锦帆，劫四方，快意逍遥！",
  ["$blitz__jinfan2"] = "铃声所至之处，再无安宁！",
  ["$blitz__sheque1"] = "看我此箭，取那轻舟冒进之人性命！",
  ["$blitz__sheque2"] = "纵有劲甲良盾，也难挡我神射之威！",
  ["~blitz__Ganning"] = "铜铃声……怕是听不到了……",
} --甘宁（完成）

local blitz__jingce = fk.CreateTriggerSkill{
  name = "blitz__jingce",
  mute = true,
  anim_type = "drawcard",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseEnd and player.phase == Player.Start then
    return player:hasSkill(self) and target == player
    elseif event == fk.EventPhaseEnd and player.phase == Player.Finish then
    return player:hasSkill(self) and target == player and player:usedSkillTimes(self.name, Player.HistoryTurn) > 0
    and player:getMark("blitz__jingce-turn") > 0 and player:getMark("@blitz__jingce-turn") == 0
    and player:getMark("@blitz__jingce_over-turn") <= 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EventPhaseEnd and player.phase == Player.Start then
    local invoke = player.room:askForSkillInvoke(player, self.name, nil, "#blitz__jingce")
    if invoke then
      local number
      local choices = {}
      for i = 1, 99 do
        table.insert(choices, tostring(i))
      end
      number = tonumber(player.room:askForChoice(player, choices, self.name, "#blitz__jingce_num:")) ---@type integer
    if number > 0 then
      self.cost_data = number
      return true
    end
    else
    return false
    end
  elseif event == fk.EventPhaseEnd and player.phase == Player.Finish then
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.EventPhaseEnd and player.phase == Player.Start then
    player:broadcastSkillInvoke(self.name, 1)
    player.room:setPlayerMark(player, "@blitz__jingce-turn", self.cost_data)
    player.room:setPlayerMark(player, "blitz__jingce-turn", self.cost_data)
  elseif event == fk.EventPhaseEnd and player.phase == Player.Finish then
    player:broadcastSkillInvoke(self.name, 2)
    player:drawCards(player:getMark("blitz__jingce-turn"), self.name)
    end
  end,
}
local blitz__jingce_trigger = fk.CreateTriggerSkill{
  name = "#blitz__jingce_trigger",
  mute = true,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:usedSkillTimes("blitz__jingce", Player.HistoryTurn) > 0 then
      for _, move in ipairs(data) do
        if (move.moveReason == fk.ReasonResonpse or move.moveReason == fk.ReasonUse) and move.toArea == Card.DiscardPile then
          return true
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if (move.moveReason == fk.ReasonResonpse or move.moveReason == fk.ReasonUse) and move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
          if player:usedSkillTimes("blitz__jingce", Player.HistoryTurn) > 0 then
            if player:getMark("@blitz__jingce-turn") > 0 then
              player.room:removePlayerMark(player, "@blitz__jingce-turn", 1)
              if player:getMark("@blitz__jingce-turn") == 0 then
                player:broadcastSkillInvoke("blitz__jingce", 3)
                player.room:setPlayerMark(player, "@blitz__jingce_just-turn", player:getMark("blitz__jingce-turn"))
              end
            else
              if player:getMark("@blitz__jingce_just-turn") > 0 then
                player:broadcastSkillInvoke("blitz__jingce", 4)
                player.room:setPlayerMark(player, "@blitz__jingce_just-turn", 0)
              end
              player.room:addPlayerMark(player, "@blitz__jingce_over-turn", 1)
            end
          end
         end
       end
    end
  end,
}

blitz__jingce:addRelatedSkill(blitz__jingce_trigger)
Guohuai:addSkill(blitz__jingce)

Fk:loadTranslationTable{
  ["blitz__Guohuai"] = "郭淮", 
  ["#blitz__Guohuai"] = "方策精详",
  ["cv:blitz__Guohuai"] = "官方",
  ["illustrator:blitz__Guohuai"] = "凝聚永恒",
  ["designer:blitz__Guohuai"] = "那个背影",

  ["blitz__jingce"] = "精策",
  [":blitz__jingce"] = "准备阶段，你可以声明一个三位数以下的正整数X，结束阶段，若本回合因使用或打出而进入弃牌堆的牌数等于X，你摸X张牌。",
  ["#blitz__jingce"] = "是否发动 精策？",
  ["#blitz__jingce_num"] = "请为 精策 选择一个数字，若数字与本回合所有使用或打出牌数对应，结束阶段你摸等量张牌。",
  ["@blitz__jingce-turn"] = "精策 未至",
  ["@blitz__jingce_just-turn"] = "精策 就绪",
  ["@blitz__jingce_over-turn"] = "精策 过及",
  ["#blitz__jingce_trigger"] = "精策",

  ["$blitz__jingce1"] = "吾已料敌布防，蜀军休想进犯！",
  ["$blitz__jingce2"] = "妙策如神，精兵强将，安有不胜之理？",
  ["$blitz__jingce3"] = "诸君依策行事，定保魏境无虞！",
  ["$blitz__jingce4"] = "姜维小儿，竟然……",
  ["~blitz__Guohuai"] = "岂料姜维……空手接箭！",
} --郭淮(完成)

local blitz__zhuiyue = fk.CreateActiveSkill{
  name = "blitz__zhuiyue",
  anim_type = "control",
  card_num = 0,
  min_target_num = 1,
  max_target_num = 2,
  prompt = "#blitz__zhuiyue-prompt",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected < 2 and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local targets = {player}
    local targethits = {player}
    for _, p in ipairs(effect.tos) do
      table.insert(targethits, room:getPlayerById(p))
      if table.find(room:getPlayerById(p):getCardIds("he"), function(id) return not room:getPlayerById(p):prohibitDiscard(Fk:getCardById(id)) end) then
      table.insert(targets, room:getPlayerById(p))
      end
    end
      local cardsMap = U.askForJointCard(targets, 1, 999, true, self.name, false, ".|.|.|hand,equip", "#AskForDiscard:::1:1:999", nil, true)
      local moveInfos = {}
      local types = {"basic", "trick", "equip"}
      for _, p in ipairs(targets) do
        local throw = cardsMap[p.id]
        if throw then
          for _, id in ipairs(throw) do
            table.removeOne(types, Fk:getCardById(id):getTypeString())
          end
          table.insert(moveInfos, {
            ids = throw,
            from = p.id,
            toArea = Card.DiscardPile,
            moveReason = fk.ReasonDiscard,
            proposer = p.id,
            skillName = self.name,
          })
        end
      end
      room:moveCards(table.unpack(moveInfos))
      if #types > 0 then
      local cards = {}
      for _, type in ipairs(types) do
        local card = room:getCardsFromPileByRule(".|.|.|.|.|"..type)
        if card then
          table.insert(cards, card[1])
        end
      end
      if #cards > 0 then
        room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
      end
    else
      for _, p in ipairs(targethits) do
        if not p.dead then
        room:damage{
          from = player,
          to = p,
          damage = 1,
          skillName = self.name,
        }
      end
      end
      end
  end,
}
local blitz__mouli = fk.CreateTriggerSkill{
  name = "blitz__mouli",
  mute = true,
  frequency = Skill.Limited,
  events = {fk.EventPhaseStart, fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseStart and player.phase == Player.Start then
    return target == player and player:hasSkill(self) and
      player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    elseif event == fk.TurnEnd then
      local x = 0
      player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 999, function(e)
        local damage = e.data[5]
        if damage and damage.from == player then
          x = x + damage.damage
        end
      end, Player.HistoryTurn)
    return target == player and player:usedSkillTimes(self.name, Player.HistoryGame) > 0
    and player:usedSkillTimes(self.name, Player.HistoryTurn) > 0 and x < 3
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
    return player.room:askForSkillInvoke(player, self.name, nil, "#blitz__mouli")
  elseif event == fk.TurnEnd then
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.EventPhaseStart then
      player.room:notifySkillInvoked(player, self.name, "big")
      player:broadcastSkillInvoke(self.name, math.random(2))
      player.room:handleAddLoseSkills(player, "blitz__quanji|blitz__hezhi", nil, true, false)
  elseif event == fk.TurnEnd then
      player:broadcastSkillInvoke(self.name, 3)
      player.room:handleAddLoseSkills(player, "-blitz__quanji|-blitz__hezhi", nil, true, false)
    end
  end,
}
--直接复制手杀界权计的代码了（）
local blitz__quanji = fk.CreateTriggerSkill{
  name = "blitz__quanji",
  anim_type = "masochism",
  derived_piles = "blitz__zhonghui_quan",
  events = {fk.Damaged, fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
    (event == fk.Damaged or (player.phase == Player.Play and player:getHandcardNum() > player.hp))
  end,
  on_trigger = function(self, event, target, player, data)
    local x = (event == fk.Damaged) and data.damage or 1
    self.cancel_cost = false
    for i = 1, x do
      if self.cancel_cost or not player:hasSkill(self) then break end
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askForSkillInvoke(player, self.name, data) then
      return true
    end
    self.cancel_cost = true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    if not (player.dead or player:isKongcheng()) then
      local card = room:askForCard(player, 1, 1, false, self.name, false, nil, nil)
      player:addToPile("blitz__zhonghui_quan", card, true, self.name)
    end
  end,
}
local blitz__quanji_maxcards = fk.CreateMaxCardsSkill{
  name = "#blitz__quanji_maxcards",
  correct_func = function(self, player)
    if player:hasSkill(blitz__quanji) then
      return #player:getPile("blitz__zhonghui_quan")
    else
      return 0
    end
  end,
}
local blitz__hezhi = fk.CreateTriggerSkill{
  name = "blitz__hezhi",
  mute = true,
  frequency = Skill.Limited,
  events = {fk.EnterDying, fk.Deathed},
  can_trigger = function(self, event, target, player, data)
    if event == fk.EnterDying then
    return player:hasSkill(self) and target.dying and target ~= player
    and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    elseif event == fk.Deathed then
    return player:usedSkillTimes(self.name, Player.HistoryGame) > 0 and player:getMark(self.name) == target.id
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EnterDying then
    return player.room:askForSkillInvoke(player, self.name, nil, "#blitz__hezhi-invoke::"..target.id)
  elseif event == fk.Deathed then
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EnterDying then
    room:notifySkillInvoked(player, self.name, "big")
    player:broadcastSkillInvoke(self.name, math.random(2))
    if not target.dead and target:isWounded() then
      local choices = {"joinimpart","cancel"}
      local choice = room:askForChoice(target, choices, self.name, "#blitz__hezhi-support::"..player.id, false, {"joinimpart","cancel"})
      if choice == "joinimpart" then
        room:recover({
          who = target,
          num = 1 - target.hp,
          recoverBy = player,
          skillName = self.name
        })
      room:setPlayerMark(player, "@blitz__hezhi", target.general)
      room:setPlayerMark(player, self.name, target.id)
      room:setPlayerMark(target, "@blitz__hezhi", player.general)
      room:setPlayerMark(target, self.name, player.id)
      player:addBuddy(target)
      target:addBuddy(player)
      room:handleAddLoseSkills(player, "blitz__hezhi_use&", nil, true, true)
      room:handleAddLoseSkills(target, "blitz__hezhi_use&", nil, true, true)
      local ids1 = player:getTableMark("blitz__hezhi_use")
      local ids2 = target:getTableMark("blitz__hezhi_use")
      for _, p in ipairs(room.alive_players) do
        for _, id in ipairs(p:getCardIds("h")) do
        if p:getMark(self.name) == player.id then
          table.insertIfNeed(ids1, id)
        end
        if p:getMark(self.name) == target.id then
          table.insertIfNeed(ids2, id)
        end
        end
      end
      room:setPlayerMark(player, "blitz__hezhi_use", #ids1 > 0 and ids1 or 0)
      room:setPlayerMark(target, "blitz__hezhi_use", #ids2 > 0 and ids2 or 0)
      end
    end
  elseif event == fk.Deathed then
    for _, p in ipairs(room:getAllPlayers()) do
      room:setPlayerMark(p, "@blitz__hezhi", 0)
      room:setPlayerMark(p, self.name, 0)
      room:setPlayerMark(p, "blitz__hezhi_use", 0)
      room:handleAddLoseSkills(p, "-blitz__hezhi_use&", nil, true, true)
    end
    end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    if player:getMark(self.name) ~= 0 then
      return true
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local jiangwei
    for _, p in ipairs(room:getAllPlayers()) do
      if player:getMark(self.name) == p.id then
        jiangwei = p
      end
    end
    local ids1 = player:getTableMark("blitz__hezhi_use")
    local ids2 = jiangwei:getTableMark("blitz__hezhi_use")
    for _, id in ipairs(ids1) do
      table.removeOne(ids1, id)
    end
    for _, id in ipairs(ids2) do
      table.removeOne(ids2, id)
    end
    room:setPlayerMark(player, "blitz__hezhi_use", 0)
    room:setPlayerMark(jiangwei, "blitz__hezhi_use", 0)
    for _, p in ipairs(room.alive_players) do
      for _, id in ipairs(p:getCardIds("h")) do
      if p:getMark(self.name) == player.id then
        table.insertIfNeed(ids1, id)
      elseif p:getMark(self.name) == jiangwei.id then
        table.insertIfNeed(ids2, id)
      end
      end
    end
    room:setPlayerMark(player, "blitz__hezhi_use", #ids1 > 0 and ids1 or 0)
    room:setPlayerMark(jiangwei, "blitz__hezhi_use", #ids2 > 0 and ids2 or 0)
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
    for _, p in ipairs(room:getAllPlayers()) do
      room:setPlayerMark(p, "@blitz__hezhi", 0)
      room:setPlayerMark(p, self.name, 0)
      room:setPlayerMark(p, "blitz__hezhi_use", 0)
      room:handleAddLoseSkills(p, "-blitz__hezhi_use&", nil, true, true)
    end
  end,
}
local blitz__hezhi_use = fk.CreateViewAsSkill{
  name = "blitz__hezhi_use&",
  pattern = ".",
  prompt = "#blitz__hezhi_use",
  expand_pile = function() return Self:getTableMark("blitz__hezhi_use") end,
  card_filter = function(self, to_select, selected)
    if #selected == 0 and table.contains(Self:getTableMark("blitz__hezhi_use"), to_select) then
      local card = Fk:getCardById(to_select)
      return (Fk.currentResponsePattern == nil and Self:canUse(card)) or
        (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(card))
      end
  end,
  view_as = function(self, cards)
    if #cards == 1 then
      return Fk:getCardById(cards[1])
    end
  end,
  before_use = function (self, player, use)
    player:broadcastSkillInvoke("blitz__hezhi", math.random(3,4))
    local ids = player:getTableMark("blitz__hezhi_use")
    table.removeOne(ids, use.card.id)
    player.room:setPlayerMark(player, "blitz__hezhi_use", ids)
  end,
  enabled_at_play = function (self, player) --强制锁20次了，强度不高loop特多
    return Self:usedSkillTimes(self.name, Player.HistoryPhase) < 20 and table.find(Fk:currentRoom().alive_players, function (p)
      return p:hasSkill(blitz__hezhi)
    end)
  end,
  enabled_at_response = function (self, player, response)
    return not response and Self:usedSkillTimes(self.name, Player.HistoryPhase) < 20 and table.find(Fk:currentRoom().alive_players, function (p)
      return p:hasSkill(blitz__hezhi)
    end)
  end,
}

Fk:addSkill(blitz__hezhi_use)
blitz__quanji:addRelatedSkill(blitz__quanji_maxcards)
Zhonghui:addSkill(blitz__zhuiyue)
Zhonghui:addSkill(blitz__mouli)
Zhonghui:addRelatedSkill(blitz__quanji)
Zhonghui:addRelatedSkill(blitz__hezhi)
Fk:loadTranslationTable{
  ["blitz__Zhonghui"] = "钟会", 
  ["#blitz__Zhonghui"] = "穹欲窥天",
  ["cv:blitz__Zhonghui"] = "天外之音",
  ["illustrator:blitz__Zhonghui"] = "太玄工作室",
  ["designer:blitz__Zhonghui"] = "快雪时晴",

  ["blitz__zhuiyue"] = "追月",
  [":blitz__zhuiyue"] = "出牌阶段限一次，你可与至多两名其他角色同时弃置至少一张牌；若这些牌包含全部类型，你对这些角色各造成1点伤害；反之，你从牌堆获得未包含类型的牌各一张。",
  ["blitz__mouli"] = "谋立",
  [":blitz__mouli"] = "限定技，准备阶段，你可获得“权计”“合志”，回合结束时，若你本回合你造成伤害数小于3，你失去因此获得的技能。",
  ["blitz__quanji"] = "权计",
  [":blitz__quanji"] = "出牌阶段结束时，若你的手牌数大于你的体力值，或当你受到1点伤害后，你可以摸一张牌，然后你将一张手牌置于武将牌上，称为“权”；你的手牌上限+X（X为“权”数）。",
  ["blitz__hezhi"] = "合志",
  [":blitz__hezhi"] = "限定技，其他角色进入濒死状态时，你可令其选择是否将体力值回复至1点，若其选择是，你与其手牌互相可见，并互相可将对方手牌如手牌般使用。",
  ["blitz__hezhi_use&"] = "合志",
  [":blitz__hezhi_use&"] = "你可以将你合志标记所示角色的手牌如手牌般使用，其的手牌对你可见。",
  ["#blitz__zhuiyue-prompt"] = "追月：你可选择至多两名其他角色，你与其之中可以弃牌的角色同时弃置至少一张牌；"..
  "<br>若包含全部类型，你对这些角色各造成1点伤害；反之，你从牌堆获得未包含类型的牌各一张。",
  ["#blitz__mouli"] = "是否发动 谋立，获得 权计 和 合志 （但若你本回合造成伤害数值小于3，这些技能于回合结束时失去）？",
  ["blitz__zhonghui_quan"] = "权",
  ["joinimpart"] = "回复至1体力，本局与钟会手牌互相可见可用",
  ["#blitz__hezhi-invoke"] = "合志：%dest 濒死，是否令其选择回复1点体力并且可以和你互相用手牌？",
  ["#blitz__hezhi-support"] = "%dest 向你发起了 合志 请求，是否回复至1点体力，与其达成合作？",
  ["@blitz__hezhi"] = "合志",
  ["#blitz__hezhi_use"] = "你可以将你合志标记所示角色的手牌如手牌般使用！",

  ["$blitz__zhuiyue1"] = "会欲效周公吐哺故事，教四方英才来效！",
  ["$blitz__zhuiyue2"] = "会久慕将军大名，得遇知己，当浮三大白！",
  ["$blitz__mouli1"] = "大军扬武，英雄归附，会此时不取，更待何时？",
  ["$blitz__mouli2"] = "灭国功成，天下名震，会今夕不立，更复何期？",
  ["$blitz__mouli3"] = "虽邓艾争功，司马怀忌，会犹有七尺之身，五斗之才，来日当东山再起！",
  ["$blitz__quanji1"] = "十载光阴已历，欲成大业，又岂在朝夕？",
  ["$blitz__quanji2"] = "百里士众虽服，志向雄主，当归心天下！",
  ["$blitz__hezhi1"] = "今与将军为复汉元勋，吾为天下之主，君则领天下兵马！",
  ["$blitz__hezhi2"] = "举大事者怎可拘小节？钟某诚心相邀，还望伯约兄勿辞！",
  ["$blitz__hezhi3"] = "（用牌/钟会）万顷中原，取之不过覆手！",
  ["$blitz__hezhi4"] = "（用牌/姜维）千里蜀川，复之只在一炬！",
  ["~blitz__Zhonghui"] = "吾自以策数精炼于世，如今观之，不过如此...哈哈哈哈...啊！",
} --钟会(完成)

local blitz__jielve = fk.CreateTriggerSkill{
  name = "blitz__jielve",
  anim_type = "support",
  events = {fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player then
      local events = player.room.logic:getActualDamageEvents(1, function(e)
        return e.data[1].from == player
      end, Player.HistoryTurn)
      return #events == 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local prompt
    if not data.to:isWounded() then
      prompt =  "#blitz__jielve1"
    else
      prompt =  "#blitz__jielve2"
    end
    local to = player.room:askForChoosePlayers(player, table.map(player.room:getAlivePlayers(), Util.IdMapper), 1, 1, prompt, self.name, false)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end      
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    if not data.to:isWounded()  then
    room:changeShield(to, 1)
  else
    if data.to:isNude() then return end
    local id = room:askForCardChosen(to, data.to, "he", self.name)
    room:obtainCard(to, id, false, fk.ReasonPrey, player.id, self.name)
  end
  end,
}
local blitz__yezhuchongfeng = fk.CreateActiveSkill{
  name = "blitz__yezhuchongfeng",
  anim_type = "support",
  prompt = "#blitz__yezhuchongfeng_use",
  min_card_num = 0,
  min_target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    target:drawCards(1, self.name, nil)
    local slash = Fk:cloneCard("slash")
    local targets = table.filter(room.alive_players, function(p) return not target:isProhibited(p, slash) and p ~= player and p ~= target end)
    if #targets > 0 then
      local tos = room:askForChoosePlayers(target, table.map(targets, Util.IdMapper), 1, 1, "#blitz__yezhuchongfeng-choose", self.name, false)
      if #tos > 0 then
      local to = room:getPlayerById(tos[1])
        room:useCard{
          from = target.id,
          card = slash,
          tos = { { to.id } },
          extraUse = true,
        }
      if not to.dead and not target.dead and not to:isProhibited(target, slash) then
        room:useCard{
          from = to.id,
          card = slash,
          tos = { { target.id } },
          extraUse = true,
        }
        end
      end
    end
  end,
}
local blitz__haishangbaquan = fk.CreateTriggerSkill{
  name = "blitz__haishangbaquan$",
  anim_type = "support",
  events = {fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    local events = player.room.logic:getActualDamageEvents(999, function(e)
      return e.data[1].from == target
    end, Player.HistoryTurn)
    return target and player:hasSkill(self) and target ~= player and target.kingdom == "qun"
     and #events == 0 and data.to and not target.dead
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(target, self.name, nil, "#blitz__haishangbaquan-invoke:"..player.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, "blitz__jielve", nil, data.to)
    if not data.to:isWounded() then
      room:changeShield(player, 1)
    else
      if data.to:isNude() then return end
      local id = room:askForCardChosen(player, data.to, "he", "blitz__jielve")
      room:obtainCard(player, id, false, fk.ReasonPrey, player.id, "blitz__jielve")
    end
  end
}
Craite:addSkill(blitz__jielve)
Craite:addSkill(blitz__yezhuchongfeng)
Craite:addSkill(blitz__haishangbaquan)
Fk:loadTranslationTable{
  ["blitz__Craite"] = "克拉茨·奎特",
  ["#blitz__Craite"] = "海上野猪",
  ["cv:blitz__Craite"] = "巫师：昆特牌",
  ["illustrator:blitz__Craite"] = "巫师：昆特牌",
  ["designer:blitz__Craite"] = "黑寡妇无敌",

  ["blitz__jielve"] = "劫掠",
  [":blitz__jielve"] = "锁定技，你每回合首次造成伤害时，若受伤角色未受伤，你令一名角色获得1点护甲，否则你令一名角色获得受伤角色一张牌。",
  ["blitz__yezhuchongfeng"] = "野猪冲锋",
  [":blitz__yezhuchongfeng"] = "出牌阶段限一次，你可以令一名角色摸一张牌，然后其视为对除你以外的一名角色使用一张【杀】，结算后，目标角色视为对其使用一张【杀】。",
  ["blitz__haishangbaquan"] = "海上霸权",
  [":blitz__haishangbaquan"] = "主公技，其他群势力角色每回合首次造成伤害时，其可以令你对受伤角色发动“劫掠”。"..
  "<br><font color='grey'>暂定为自己根据受伤角色情况执行获得护甲或牌。",
  ["#blitz__jielve1"] = "劫掠：令一名角色获得1点护甲。",
  ["#blitz__jielve2"] = "劫掠：令一名角色获得受伤角色一张牌。",
  ["#blitz__yezhuchongfeng_use"] = "野猪冲锋：一名角色摸一张牌，然后其视为对除你以外的一名角色互相使用一张【杀】。",
  ["#blitz__yezhuchongfeng-choose"] = "野猪冲锋：请视为对一名除发动本技能角色外的角色使用【杀】（无距离次数限制，结算后其也视为对你使用一张【杀】）。",
  ["#blitz__haishangbaquan-invoke"] = "海上霸权：你可以令 %src 对受伤角色发动“劫掠”，其获得1点护甲或受伤角色的一张牌。",

  ["$blitz__jielve"] = "为了奎特家族！",
  ["$blitz__yezhuchongfeng"] = "你竟敢挑战我海之野猪？！",
  ["$blitz__haishangbaquan1"] = "你有着我们奎特家族的精神。",
  ["$blitz__haishangbaquan2"] = "为了史凯利杰的荣耀！",
  ["~blitz__Craite"] = "",
} --克拉茨·奎特(完成)

return extension